ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ForkJoinPool8Test.java
(Generate patch)

Comparing jsr166/src/test/tck/ForkJoinPool8Test.java (file contents):
Revision 1.26 by jsr166, Sat Nov 1 16:02:23 2014 UTC vs.
Revision 1.31 by jsr166, Sun Oct 4 07:26:09 2015 UTC

# Line 4 | Line 4
4   * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7 < import junit.framework.*;
7 > import static java.util.concurrent.TimeUnit.MILLISECONDS;
8 > import static java.util.concurrent.TimeUnit.SECONDS;
9 >
10 > import java.util.HashSet;
11   import java.util.concurrent.CancellationException;
12 + import java.util.concurrent.CountedCompleter;
13   import java.util.concurrent.ExecutionException;
14   import java.util.concurrent.ForkJoinPool;
15   import java.util.concurrent.ForkJoinTask;
12 import java.util.concurrent.ForkJoinWorkerThread;
16   import java.util.concurrent.RecursiveAction;
14 import java.util.concurrent.CountedCompleter;
15 import java.util.concurrent.ThreadLocalRandom;
16 import java.util.concurrent.TimeUnit;
17   import java.util.concurrent.TimeoutException;
18 < import static java.util.concurrent.TimeUnit.SECONDS;
19 < import static java.util.concurrent.TimeUnit.MILLISECONDS;
20 < import java.util.Arrays;
21 < import java.util.HashSet;
18 >
19 > import junit.framework.Test;
20 > import junit.framework.TestSuite;
21  
22   public class ForkJoinPool8Test extends JSR166TestCase {
23      public static void main(String[] args) {
24 <        junit.textui.TestRunner.run(suite());
24 >        main(suite(), args);
25      }
26  
27      public static Test suite() {
# Line 479 | Line 478 | public class ForkJoinPool8Test extends J
478                  FailingFibAction f = new FailingFibAction(8);
479                  assertSame(f, f.fork());
480                  try {
481 <                    f.get(5L, TimeUnit.SECONDS);
481 >                    f.get(5L, SECONDS);
482                      shouldThrow();
483                  } catch (ExecutionException success) {
484                      Throwable cause = success.getCause();
# Line 1490 | Line 1489 | public class ForkJoinPool8Test extends J
1489       */
1490      public void testAwaitQuiescence1() throws Exception {
1491          final ForkJoinPool p = new ForkJoinPool();
1492 <        try {
1492 >        try (PoolCleaner cleaner = cleaner(p)) {
1493              final long startTime = System.nanoTime();
1494              assertTrue(p.isQuiescent());
1495              ForkJoinTask a = new CheckedRecursiveAction() {
# Line 1531 | Line 1530 | public class ForkJoinPool8Test extends J
1530              assertFalse(p.isShutdown());
1531              assertFalse(p.isTerminating());
1532              assertFalse(p.isTerminated());
1534        } finally {
1535            joinPool(p);
1533          }
1534      }
1535  
# Line 1541 | Line 1538 | public class ForkJoinPool8Test extends J
1538       * timeout elapsed
1539       */
1540      public void testAwaitQuiescence2() throws Exception {
1541 +        /**
1542 +         * """It is possible to disable or limit the use of threads in the
1543 +         * common pool by setting the parallelism property to zero. However
1544 +         * doing so may cause unjoined tasks to never be executed."""
1545 +         */
1546 +        if ("0".equals(System.getProperty(
1547 +             "java.util.concurrent.ForkJoinPool.common.parallelism")))
1548 +            return;
1549          final ForkJoinPool p = new ForkJoinPool();
1550 <        try {
1550 >        try (PoolCleaner cleaner = cleaner(p)) {
1551              assertTrue(p.isQuiescent());
1552              final long startTime = System.nanoTime();
1553              ForkJoinTask a = new CheckedRecursiveAction() {
# Line 1575 | Line 1580 | public class ForkJoinPool8Test extends J
1580              assertFalse(p.isShutdown());
1581              assertFalse(p.isTerminating());
1582              assertFalse(p.isTerminated());
1578        } finally {
1579            joinPool(p);
1583          }
1584      }
1585  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines