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

Comparing jsr166/src/test/tck/CyclicBarrierTest.java (file contents):
Revision 1.27 by jsr166, Sat Apr 25 04:55:30 2015 UTC vs.
Revision 1.28 by jsr166, Thu Sep 15 01:18:01 2016 UTC

# Line 13 | Line 13 | import java.util.concurrent.CountDownLat
13   import java.util.concurrent.CyclicBarrier;
14   import java.util.concurrent.TimeoutException;
15   import java.util.concurrent.atomic.AtomicBoolean;
16 + import java.util.concurrent.atomic.AtomicInteger;
17  
18   import junit.framework.Test;
19   import junit.framework.TestSuite;
# Line 25 | Line 26 | public class CyclicBarrierTest extends J
26          return new TestSuite(CyclicBarrierTest.class);
27      }
28  
28    private volatile int countAction;
29    private class MyAction implements Runnable {
30        public void run() { ++countAction; }
31    }
32
29      /**
30       * Spin-waits till the number of waiters == numberOfWaiters.
31       */
# Line 87 | Line 83 | public class CyclicBarrierTest extends J
83       * The supplied barrier action is run at barrier
84       */
85      public void testBarrierAction() throws Exception {
86 <        countAction = 0;
87 <        CyclicBarrier b = new CyclicBarrier(1, new MyAction());
86 >        final AtomicInteger count = new AtomicInteger(0);
87 >        final Runnable incCount = new Runnable() { public void run() {
88 >            count.getAndIncrement(); }};
89 >        CyclicBarrier b = new CyclicBarrier(1, incCount);
90          assertEquals(1, b.getParties());
91          assertEquals(0, b.getNumberWaiting());
92          b.await();
93          b.await();
94          assertEquals(0, b.getNumberWaiting());
95 <        assertEquals(2, countAction);
95 >        assertEquals(2, count.get());
96      }
97  
98      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines