--- jsr166/src/test/tck/AtomicLongArrayTest.java 2015/04/25 04:55:30 1.31 +++ jsr166/src/test/tck/AtomicLongArrayTest.java 2021/01/26 13:33:05 1.38 @@ -54,6 +54,7 @@ public class AtomicLongArrayTest extends /** * get and set for out of bound indices throw IndexOutOfBoundsException */ + @SuppressWarnings("deprecation") public void testIndexing() { AtomicLongArray aa = new AtomicLongArray(SIZE); for (int index : new int[] { -1, SIZE }) { @@ -159,6 +160,7 @@ public class AtomicLongArrayTest extends * repeated weakCompareAndSet succeeds in changing value when equal * to expected */ + @SuppressWarnings("deprecation") public void testWeakCompareAndSet() { AtomicLongArray aa = new AtomicLongArray(SIZE); for (int i = 0; i < SIZE; i++) { @@ -275,7 +277,7 @@ public class AtomicLongArrayTest extends class Counter extends CheckedRunnable { final AtomicLongArray aa; - volatile long counts; + int decs; Counter(AtomicLongArray a) { aa = a; } public void realRun() { for (;;) { @@ -285,8 +287,8 @@ public class AtomicLongArrayTest extends assertTrue(v >= 0); if (v != 0) { done = false; - if (aa.compareAndSet(i, v, v-1)) - ++counts; + if (aa.compareAndSet(i, v, v - 1)) + decs++; } } if (done) @@ -306,17 +308,15 @@ public class AtomicLongArrayTest extends aa.set(i, countdown); Counter c1 = new Counter(aa); Counter c2 = new Counter(aa); - Thread t1 = new Thread(c1); - Thread t2 = new Thread(c2); - t1.start(); - t2.start(); + Thread t1 = newStartedThread(c1); + Thread t2 = newStartedThread(c2); t1.join(); t2.join(); - assertEquals(c1.counts+c2.counts, SIZE * countdown); + assertEquals(c1.decs + c2.decs, SIZE * countdown); } /** - * a deserialized serialized array holds same values + * a deserialized/reserialized array holds same values in same order */ public void testSerialization() throws Exception { AtomicLongArray x = new AtomicLongArray(SIZE);