1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
|
import junit.framework.*; |
9 |
|
import java.util.concurrent.ExecutionException; |
10 |
|
import java.util.concurrent.ForkJoinPool; |
11 |
|
import java.util.concurrent.ForkJoinTask; |
12 |
– |
import java.util.concurrent.ForkJoinWorkerThread; |
12 |
|
import java.util.concurrent.RecursiveTask; |
14 |
– |
import java.util.concurrent.TimeUnit; |
13 |
|
import java.util.concurrent.TimeoutException; |
14 |
|
import static java.util.concurrent.TimeUnit.SECONDS; |
15 |
|
import java.util.HashSet; |
317 |
|
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
318 |
|
} |
319 |
|
|
322 |
– |
|
320 |
|
/** |
321 |
|
* helpQuiesce returns when tasks are complete. |
322 |
|
* getQueuedTaskCount returns 0 when quiescent |
326 |
|
public Integer realCompute() { |
327 |
|
FibTask f = new FibTask(8); |
328 |
|
assertSame(f, f.fork()); |
329 |
< |
f.helpQuiesce(); |
329 |
> |
helpQuiesce(); |
330 |
|
assertEquals(0, getQueuedTaskCount()); |
331 |
|
checkCompletedNormally(f, 21); |
332 |
|
return NoResult; |
334 |
|
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
335 |
|
} |
336 |
|
|
340 |
– |
|
337 |
|
/** |
338 |
|
* invoke task throws exception when task completes abnormally |
339 |
|
*/ |
759 |
|
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
760 |
|
} |
761 |
|
|
766 |
– |
|
762 |
|
/** |
763 |
|
* invokeAll(tasks) with any null task throws NPE |
764 |
|
*/ |