--- jsr166/src/test/tck/PhaserTest.java 2011/09/21 12:33:56 1.35 +++ jsr166/src/test/tck/PhaserTest.java 2015/04/25 04:55:31 1.40 @@ -5,21 +5,22 @@ * Other contributors include John Vint */ -import junit.framework.*; +import static java.util.concurrent.TimeUnit.MILLISECONDS; + import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Phaser; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Phaser; import java.util.concurrent.TimeoutException; -import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static java.util.concurrent.TimeUnit.NANOSECONDS; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import junit.framework.Test; +import junit.framework.TestSuite; + public class PhaserTest extends JSR166TestCase { public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); + main(suite(), args); } public static Test suite() { @@ -197,10 +198,22 @@ public class PhaserTest extends JSR166Te Phaser child1 = new Phaser(root, 1); Phaser child2 = new Phaser(root, 0); assertEquals(0, child2.register()); + assertState(root, 0, 2, 2); + assertState(child1, 0, 1, 1); + assertState(child2, 0, 1, 1); assertEquals(0, child2.arriveAndDeregister()); + assertState(root, 0, 1, 1); + assertState(child1, 0, 1, 1); + assertState(child2, 0, 0, 0); assertEquals(0, child2.register()); assertEquals(0, child2.arriveAndDeregister()); + assertState(root, 0, 1, 1); + assertState(child1, 0, 1, 1); assertState(child2, 0, 0, 0); + assertEquals(0, child1.arriveAndDeregister()); + assertTerminated(root, 1); + assertTerminated(child1, 1); + assertTerminated(child2, 1); } /** @@ -616,7 +629,7 @@ public class PhaserTest extends JSR166Te count.incrementAndGet(); assertEquals(2*k+1, phaser.arrive()); assertEquals(2*k+2, phaser.awaitAdvance(2*k+1)); - assertEquals(count.get(), 4*(k+1)); + assertEquals(4*(k+1), count.get()); }}})); for (Thread thread : threads)