41 |
|
assertEquals(3, p.setParallelism(2)); |
42 |
|
p.shutdown(); |
43 |
|
} |
44 |
+ |
|
45 |
|
/** |
46 |
|
* SetParallelism throws exception if argument out of bounds |
47 |
|
*/ |
61 |
|
p.shutdown(); |
62 |
|
} |
63 |
|
|
64 |
< |
|
64 |
> |
|
65 |
|
/* |
66 |
|
* Some test methods adapted from RecursiveAction |
67 |
|
*/ |
466 |
|
} |
467 |
|
} |
468 |
|
|
469 |
+ |
/** |
470 |
+ |
* Implictly closing a new pool using try-with-resources terminates it |
471 |
+ |
*/ |
472 |
+ |
public void testClose() { |
473 |
+ |
ForkJoinTask f = new FibAction(8); |
474 |
+ |
ForkJoinPool pool = null; |
475 |
+ |
try (ForkJoinPool p = new ForkJoinPool()) { |
476 |
+ |
pool = p; |
477 |
+ |
p.execute(f); |
478 |
+ |
} |
479 |
+ |
checkCompletedNormally(f); |
480 |
+ |
assertTrue(pool != null && pool.isTerminated()); |
481 |
+ |
} |
482 |
+ |
|
483 |
+ |
/** |
484 |
+ |
* Implictly closing commonpool using try-with-resources does not |
485 |
+ |
* terminate it |
486 |
+ |
*/ |
487 |
+ |
public void testCloseCommonPool() { |
488 |
+ |
ForkJoinTask f = new FibAction(8); |
489 |
+ |
ForkJoinPool pool; |
490 |
+ |
try (ForkJoinPool p = ForkJoinPool.commonPool()) { |
491 |
+ |
pool = p; |
492 |
+ |
p.execute(f); |
493 |
+ |
} |
494 |
+ |
assertFalse(pool.isTerminated()); |
495 |
+ |
} |
496 |
|
} |