changeset 4419:549b7c3f0bdc

7058828: test/java/util/concurrent/Phaser/Arrive.java fails intermittently Reviewed-by: chegar
author dl
date Tue, 12 Jul 2011 15:23:23 +0100
parents 5adf431673ac
children 42fe05e54e69
files test/java/util/concurrent/Phaser/Arrive.java
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/util/concurrent/Phaser/Arrive.java	Tue Jul 12 07:32:29 2011 +0900
+++ b/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);
     }