465 |
|
} |
466 |
|
} |
467 |
|
|
468 |
+ |
/** |
469 |
+ |
* Implictly closing a new pool using try-with-resources terminates it |
470 |
+ |
*/ |
471 |
+ |
public void testClose() { |
472 |
+ |
ForkJoinTask f = new FibAction(8); |
473 |
+ |
ForkJoinPool pool = null; |
474 |
+ |
try (ForkJoinPool p = new ForkJoinPool()) { |
475 |
+ |
pool = p; |
476 |
+ |
p.execute(f); |
477 |
+ |
} |
478 |
+ |
checkCompletedNormally(f); |
479 |
+ |
assertTrue(pool != null && pool.isTerminated()); |
480 |
+ |
} |
481 |
+ |
|
482 |
+ |
/** |
483 |
+ |
* Implictly closing commonpool using try-with-resources does not |
484 |
+ |
* terminate it |
485 |
+ |
*/ |
486 |
+ |
public void testCloseCommonPool() { |
487 |
+ |
ForkJoinTask f = new FibAction(8); |
488 |
+ |
ForkJoinPool pool; |
489 |
+ |
try (ForkJoinPool p = ForkJoinPool.commonPool()) { |
490 |
+ |
pool = p; |
491 |
+ |
p.execute(f); |
492 |
+ |
} |
493 |
+ |
assertFalse(pool.isTerminated()); |
494 |
+ |
} |
495 |
|
} |