10 |
|
import java.util.concurrent.atomic.*; |
11 |
|
|
12 |
|
public class AtomicStampedReferenceTest extends JSR166TestCase { |
13 |
< |
public static void main (String[] args) { |
14 |
< |
junit.textui.TestRunner.run (suite()); |
13 |
> |
public static void main(String[] args) { |
14 |
> |
junit.textui.TestRunner.run(suite()); |
15 |
|
} |
16 |
|
public static Test suite() { |
17 |
|
return new TestSuite(AtomicStampedReferenceTest.class); |
30 |
|
} |
31 |
|
|
32 |
|
/** |
33 |
< |
* get returns the last values of reference and stamp set |
33 |
> |
* get returns the last values of reference and stamp set |
34 |
|
*/ |
35 |
|
public void testGetSet() { |
36 |
|
int[] mark = new int[1]; |
52 |
|
} |
53 |
|
|
54 |
|
/** |
55 |
< |
* attemptStamp succeeds in single thread |
55 |
> |
* attemptStamp succeeds in single thread |
56 |
|
*/ |
57 |
|
public void testAttemptStamp() { |
58 |
|
int[] mark = new int[1]; |
136 |
|
int[] mark = new int[1]; |
137 |
|
AtomicStampedReference ai = new AtomicStampedReference(one, 0); |
138 |
|
assertSame(one, ai.get(mark)); |
139 |
< |
assertEquals(0, ai.getStamp ()); |
139 |
> |
assertEquals(0, ai.getStamp()); |
140 |
|
assertEquals(0, mark[0]); |
141 |
|
|
142 |
|
while (!ai.weakCompareAndSet(one, two, 0, 0)); |