548 |
|
public void testInterruptedSubmit() throws InterruptedException { |
549 |
|
final CountDownLatch submitted = new CountDownLatch(1); |
550 |
|
final CountDownLatch quittingTime = new CountDownLatch(1); |
551 |
– |
final ExecutorService p = new ForkJoinPool(1); |
551 |
|
final Callable<Void> awaiter = new CheckedCallable<Void>() { |
552 |
|
public Void realCall() throws InterruptedException { |
553 |
< |
assertTrue(quittingTime.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
553 |
> |
assertTrue(quittingTime.await(2*LONG_DELAY_MS, MILLISECONDS)); |
554 |
|
return null; |
555 |
|
}}; |
556 |
< |
try { |
556 |
> |
final ExecutorService p = new ForkJoinPool(1); |
557 |
> |
try (PoolCleaner cleaner = cleaner(p, quittingTime)) { |
558 |
|
Thread t = new Thread(new CheckedInterruptedRunnable() { |
559 |
|
public void realRun() throws Exception { |
560 |
|
Future<Void> future = p.submit(awaiter); |
562 |
|
future.get(); |
563 |
|
}}); |
564 |
|
t.start(); |
565 |
< |
assertTrue(submitted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
565 |
> |
await(submitted); |
566 |
|
t.interrupt(); |
567 |
< |
t.join(); |
568 |
< |
} finally { |
569 |
< |
quittingTime.countDown(); |
570 |
< |
joinPool(p); |
567 |
> |
awaitTermination(t); |
568 |
|
} |
569 |
|
} |
570 |
|
|
910 |
|
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
911 |
|
l.add(new NPETask()); |
912 |
|
List<Future<String>> futures |
913 |
< |
= e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS); |
913 |
> |
= e.invokeAll(l, LONG_DELAY_MS, MILLISECONDS); |
914 |
|
assertEquals(1, futures.size()); |
915 |
|
try { |
916 |
|
futures.get(0).get(); |