12 |
|
import java.util.*; |
13 |
|
|
14 |
|
public class AtomicLongArrayTest extends JSR166TestCase { |
15 |
< |
public static void main (String[] args) { |
16 |
< |
junit.textui.TestRunner.run (suite()); |
15 |
> |
public static void main(String[] args) { |
16 |
> |
junit.textui.TestRunner.run(suite()); |
17 |
|
} |
18 |
|
public static Test suite() { |
19 |
|
return new TestSuite(AtomicLongArrayTest.class); |
161 |
|
} |
162 |
|
|
163 |
|
/** |
164 |
< |
* getAndSet returns previous value and sets to given value at given index |
164 |
> |
* getAndSet returns previous value and sets to given value at given index |
165 |
|
*/ |
166 |
|
public void testGetAndSet() { |
167 |
|
AtomicLongArray ai = new AtomicLongArray(SIZE); |
174 |
|
} |
175 |
|
|
176 |
|
/** |
177 |
< |
* getAndAdd returns previous value and adds given value |
177 |
> |
* getAndAdd returns previous value and adds given value |
178 |
|
*/ |
179 |
|
public void testGetAndAdd() { |
180 |
|
AtomicLongArray ai = new AtomicLongArray(SIZE); |
218 |
|
} |
219 |
|
|
220 |
|
/** |
221 |
< |
* addAndGet adds given value to current, and returns current value |
221 |
> |
* addAndGet adds given value to current, and returns current value |
222 |
|
*/ |
223 |
|
public void testAddAndGet() { |
224 |
|
AtomicLongArray ai = new AtomicLongArray(SIZE); |
264 |
|
|
265 |
|
static final long COUNTDOWN = 100000; |
266 |
|
|
267 |
< |
class Counter implements Runnable { |
267 |
> |
class Counter extends CheckedRunnable { |
268 |
|
final AtomicLongArray ai; |
269 |
|
volatile long counts; |
270 |
|
Counter(AtomicLongArray a) { ai = a; } |
271 |
< |
public void run() { |
271 |
> |
public void realRun() { |
272 |
|
for (;;) { |
273 |
|
boolean done = true; |
274 |
|
for (int i = 0; i < ai.length(); ++i) { |
275 |
|
long v = ai.get(i); |
276 |
< |
threadAssertTrue(v >= 0); |
276 |
> |
assertTrue(v >= 0); |
277 |
|
if (v != 0) { |
278 |
|
done = false; |
279 |
|
if (ai.compareAndSet(i, v, v-1)) |