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

Comparing jsr166/src/test/tck/AtomicLongArrayTest.java (file contents):
Revision 1.26 by jsr166, Thu May 30 03:28:55 2013 UTC vs.
Revision 1.30 by jsr166, Sun Feb 22 04:34:44 2015 UTC

# Line 6 | Line 6
6   * Pat Fisher, Mike Judd.
7   */
8  
9 import junit.framework.*;
9   import java.util.Arrays;
10   import java.util.concurrent.atomic.AtomicLongArray;
11  
12 + import junit.framework.Test;
13 + import junit.framework.TestSuite;
14 +
15   public class AtomicLongArrayTest extends JSR166TestCase {
16      public static void main(String[] args) {
17          junit.textui.TestRunner.run(suite());
# Line 33 | Line 35 | public class AtomicLongArrayTest extends
35      public void testConstructor2NPE() {
36          try {
37              long[] a = null;
38 <            AtomicLongArray aa = new AtomicLongArray(a);
38 >            new AtomicLongArray(a);
39              shouldThrow();
40          } catch (NullPointerException success) {}
41      }
# Line 161 | Line 163 | public class AtomicLongArrayTest extends
163          AtomicLongArray aa = new AtomicLongArray(SIZE);
164          for (int i = 0; i < SIZE; i++) {
165              aa.set(i, 1);
166 <            while (!aa.weakCompareAndSet(i, 1, 2));
167 <            while (!aa.weakCompareAndSet(i, 2, -4));
166 >            do {} while (!aa.weakCompareAndSet(i, 1, 2));
167 >            do {} while (!aa.weakCompareAndSet(i, 2, -4));
168              assertEquals(-4, aa.get(i));
169 <            while (!aa.weakCompareAndSet(i, -4, 7));
169 >            do {} while (!aa.weakCompareAndSet(i, -4, 7));
170              assertEquals(7, aa.get(i));
171          }
172      }
# Line 271 | Line 273 | public class AtomicLongArrayTest extends
273          }
274      }
275  
274    static final long COUNTDOWN = 100000;
275
276      class Counter extends CheckedRunnable {
277          final AtomicLongArray aa;
278          volatile long counts;
# Line 301 | Line 301 | public class AtomicLongArrayTest extends
301       */
302      public void testCountingInMultipleThreads() throws InterruptedException {
303          final AtomicLongArray aa = new AtomicLongArray(SIZE);
304 +        long countdown = 10000;
305          for (int i = 0; i < SIZE; i++)
306 <            aa.set(i, COUNTDOWN);
306 >            aa.set(i, countdown);
307          Counter c1 = new Counter(aa);
308          Counter c2 = new Counter(aa);
309          Thread t1 = new Thread(c1);
# Line 311 | Line 312 | public class AtomicLongArrayTest extends
312          t2.start();
313          t1.join();
314          t2.join();
315 <        assertEquals(c1.counts+c2.counts, SIZE * COUNTDOWN);
315 >        assertEquals(c1.counts+c2.counts, SIZE * countdown);
316      }
317  
318      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines