7058828: test/java/util/concurrent/Phaser/Arrive.java fails intermittently
authordl
Tue, 12 Jul 2011 15:23:23 +0100
changeset 10117 a5f22ff57f3c
parent 10116 21755833398f
child 10118 c22b087661be
7058828: test/java/util/concurrent/Phaser/Arrive.java fails intermittently Reviewed-by: chegar
jdk/test/java/util/concurrent/Phaser/Arrive.java
--- a/jdk/test/java/util/concurrent/Phaser/Arrive.java	Tue Jul 12 07:32:29 2011 +0900
+++ b/jdk/test/java/util/concurrent/Phaser/Arrive.java	Tue Jul 12 15:23:23 2011 +0100
@@ -45,9 +45,12 @@
 
 public class Arrive {
     void test(String[] args) throws Throwable {
+        for (int i = 0; i < 100; ++i)
+            doTest(args);
+    }
+    void doTest(String[] args) throws Throwable {
         final int n = ThreadLocalRandom.current().nextInt(1, 10);
-        final int nthreads = n*3/2;
-        final Phaser startingGate = new Phaser(nthreads);
+        final Phaser startingGate = new Phaser(n);
         final Phaser phaser = new Phaser(n);
         final List<Thread> threads = new ArrayList<Thread>();
         final AtomicInteger count0 = new AtomicInteger(0);
@@ -64,14 +67,14 @@
             else
                 fail();
         }};
-        for (int i = 0; i < nthreads; i++)
+        for (int i = 0; i < n; i++)
             threads.add(new Thread(task));
         for (Thread thread : threads)
             thread.start();
         for (Thread thread : threads)
             thread.join();
         equal(count0.get(), n);
-        equal(count1.get(), nthreads-n);
+        equal(count1.get(), 0);
         equal(phaser.getPhase(), 1);
     }