ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/AbstractExecutorServiceTest.java
(Generate patch)

Comparing jsr166/src/test/tck/AbstractExecutorServiceTest.java (file contents):
Revision 1.24 by jsr166, Wed Aug 25 00:07:02 2010 UTC vs.
Revision 1.25 by jsr166, Thu Sep 16 02:54:10 2010 UTC

# Line 212 | Line 212 | public class AbstractExecutorServiceTest
212  
213  
214      /**
215 <     *  Blocking on submit(callable) throws InterruptedException if
216 <     *  caller interrupted.
215 >     * submit(callable).get() throws InterruptedException if interrupted
216       */
217      public void testInterruptedSubmit() throws InterruptedException {
218 <        final ThreadPoolExecutor p = new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10));
219 <        Thread t = new Thread(new CheckedInterruptedRunnable() {
220 <            public void realRun() throws Exception {
221 <                p.submit(new CheckedCallable<Object>() {
222 <                             public Object realCall()
223 <                                 throws InterruptedException {
224 <                                 Thread.sleep(SMALL_DELAY_MS);
225 <                                 return null;
226 <                             }}).get();
227 <            }});
228 <
229 <        t.start();
230 <        Thread.sleep(SHORT_DELAY_MS);
231 <        t.interrupt();
232 <        joinPool(p);
218 >        final CountDownLatch submitted    = new CountDownLatch(1);
219 >        final CountDownLatch quittingTime = new CountDownLatch(1);
220 >        final ExecutorService p
221 >            = new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS,
222 >                                     new ArrayBlockingQueue<Runnable>(10));
223 >        final Callable<Void> awaiter = new CheckedCallable<Void>() {
224 >            public Void realCall() throws InterruptedException {
225 >                quittingTime.await();
226 >                return null;
227 >            }};
228 >        try {
229 >            Thread t = new Thread(new CheckedInterruptedRunnable() {
230 >                public void realRun() throws Exception {
231 >                    Future<Void> future = p.submit(awaiter);
232 >                    submitted.countDown();
233 >                    future.get();
234 >                }});
235 >            t.start();
236 >            submitted.await();
237 >            t.interrupt();
238 >            t.join();
239 >        } finally {
240 >            quittingTime.countDown();
241 >            joinPool(p);
242 >        }
243      }
244  
245      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines