13 |
|
|
14 |
|
public class AtomicIntegerArrayTest extends JSR166TestCase { |
15 |
|
|
16 |
< |
public static void main (String[] args) { |
17 |
< |
junit.textui.TestRunner.run (suite()); |
16 |
> |
public static void main(String[] args) { |
17 |
> |
junit.textui.TestRunner.run(suite()); |
18 |
|
} |
19 |
|
public static Test suite() { |
20 |
|
return new TestSuite(AtomicIntegerArrayTest.class); |
120 |
|
assertTrue(ai.compareAndSet(i, 2,-4)); |
121 |
|
assertEquals(-4,ai.get(i)); |
122 |
|
assertFalse(ai.compareAndSet(i, -5,7)); |
123 |
< |
assertFalse((7 == ai.get(i))); |
123 |
> |
assertEquals(-4,ai.get(i)); |
124 |
|
assertTrue(ai.compareAndSet(i, -4,7)); |
125 |
|
assertEquals(7,ai.get(i)); |
126 |
|
} |
266 |
|
|
267 |
|
static final int COUNTDOWN = 100000; |
268 |
|
|
269 |
< |
class Counter implements Runnable { |
269 |
> |
class Counter extends CheckedRunnable { |
270 |
|
final AtomicIntegerArray ai; |
271 |
|
volatile int counts; |
272 |
|
Counter(AtomicIntegerArray a) { ai = a; } |
273 |
< |
public void run() { |
273 |
> |
public void realRun() { |
274 |
|
for (;;) { |
275 |
|
boolean done = true; |
276 |
|
for (int i = 0; i < ai.length(); ++i) { |
277 |
|
int v = ai.get(i); |
278 |
< |
threadAssertTrue(v >= 0); |
278 |
> |
assertTrue(v >= 0); |
279 |
|
if (v != 0) { |
280 |
|
done = false; |
281 |
|
if (ai.compareAndSet(i, v, v-1)) |