4 |
|
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
< |
import junit.framework.*; |
7 |
> |
import static java.util.concurrent.TimeUnit.SECONDS; |
8 |
> |
|
9 |
> |
import java.util.Arrays; |
10 |
> |
import java.util.HashSet; |
11 |
|
import java.util.concurrent.CancellationException; |
9 |
– |
import java.util.concurrent.SynchronousQueue; |
12 |
|
import java.util.concurrent.ExecutionException; |
13 |
|
import java.util.concurrent.ForkJoinPool; |
14 |
|
import java.util.concurrent.ForkJoinTask; |
15 |
|
import java.util.concurrent.ForkJoinWorkerThread; |
16 |
|
import java.util.concurrent.RecursiveAction; |
17 |
+ |
import java.util.concurrent.SynchronousQueue; |
18 |
|
import java.util.concurrent.ThreadLocalRandom; |
16 |
– |
import java.util.concurrent.TimeUnit; |
19 |
|
import java.util.concurrent.TimeoutException; |
20 |
< |
import static java.util.concurrent.TimeUnit.SECONDS; |
21 |
< |
import java.util.Arrays; |
22 |
< |
import java.util.HashSet; |
20 |
> |
import java.util.concurrent.TimeUnit; |
21 |
> |
|
22 |
> |
import junit.framework.Test; |
23 |
> |
import junit.framework.TestSuite; |
24 |
|
|
25 |
|
public class RecursiveActionTest extends JSR166TestCase { |
26 |
|
|
505 |
|
FibAction f = new FibAction(8); |
506 |
|
assertSame(f, f.fork()); |
507 |
|
helpQuiesce(); |
508 |
+ |
while (!f.isDone()) // wait out race |
509 |
+ |
; |
510 |
|
assertEquals(21, f.result); |
511 |
|
assertEquals(0, getQueuedTaskCount()); |
512 |
|
checkCompletedNormally(f); |
592 |
|
FailingFibAction f = new FailingFibAction(8); |
593 |
|
assertSame(f, f.fork()); |
594 |
|
try { |
595 |
< |
f.get(5L, TimeUnit.SECONDS); |
595 |
> |
f.get(5L, SECONDS); |
596 |
|
shouldThrow(); |
597 |
|
} catch (ExecutionException success) { |
598 |
|
Throwable cause = success.getCause(); |