changeset 4568:1c0190388b70

7058828: test/java/util/concurrent/Phaser/Arrive.java fails intermittently Reviewed-by: chegar
author dl
date Thu, 01 Sep 2011 13:08:32 +0100
parents 791e94e7b64f
children e1077ba4f0f1
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	Thu Sep 01 13:05:08 2011 +0100
+++ b/test/java/util/concurrent/Phaser/Arrive.java	Thu Sep 01 13:08:32 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);
     }