17 |
|
import java.util.concurrent.SynchronousQueue; |
18 |
|
import java.util.concurrent.ThreadLocalRandom; |
19 |
|
import java.util.concurrent.TimeoutException; |
20 |
– |
import java.util.concurrent.TimeUnit; |
20 |
|
|
21 |
|
import junit.framework.Test; |
22 |
|
import junit.framework.TestSuite; |
24 |
|
public class RecursiveActionTest extends JSR166TestCase { |
25 |
|
|
26 |
|
public static void main(String[] args) { |
27 |
< |
junit.textui.TestRunner.run(suite()); |
27 |
> |
main(suite(), args); |
28 |
|
} |
29 |
|
|
30 |
|
public static Test suite() { |
46 |
|
} |
47 |
|
|
48 |
|
private void testInvokeOnPool(ForkJoinPool pool, RecursiveAction a) { |
49 |
< |
try { |
49 |
> |
try (PoolCleaner cleaner = cleaner(pool)) { |
50 |
|
checkNotDone(a); |
51 |
|
|
52 |
|
assertNull(pool.invoke(a)); |
53 |
|
|
54 |
|
checkCompletedNormally(a); |
56 |
– |
} finally { |
57 |
– |
joinPool(pool); |
55 |
|
} |
56 |
|
} |
57 |
|
|
423 |
|
|
424 |
|
t = newStartedThread(r); |
425 |
|
testInvokeOnPool(mainPool(), a); |
426 |
< |
awaitTermination(t, LONG_DELAY_MS); |
426 |
> |
awaitTermination(t); |
427 |
|
|
428 |
|
a.reinitialize(); |
429 |
|
t = newStartedThread(r); |
430 |
|
testInvokeOnPool(singletonPool(), a); |
431 |
< |
awaitTermination(t, LONG_DELAY_MS); |
431 |
> |
awaitTermination(t); |
432 |
|
} |
433 |
|
|
434 |
|
/** |
502 |
|
FibAction f = new FibAction(8); |
503 |
|
assertSame(f, f.fork()); |
504 |
|
helpQuiesce(); |
505 |
+ |
while (!f.isDone()) // wait out race |
506 |
+ |
; |
507 |
|
assertEquals(21, f.result); |
508 |
|
assertEquals(0, getQueuedTaskCount()); |
509 |
|
checkCompletedNormally(f); |
589 |
|
FailingFibAction f = new FailingFibAction(8); |
590 |
|
assertSame(f, f.fork()); |
591 |
|
try { |
592 |
< |
f.get(5L, TimeUnit.SECONDS); |
592 |
> |
f.get(5L, SECONDS); |
593 |
|
shouldThrow(); |
594 |
|
} catch (ExecutionException success) { |
595 |
|
Throwable cause = success.getCause(); |