6 |
|
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
8 |
|
|
9 |
– |
import junit.framework.*; |
9 |
|
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; |
10 |
|
|
11 |
+ |
import junit.framework.Test; |
12 |
+ |
import junit.framework.TestSuite; |
13 |
+ |
|
14 |
|
public class AtomicReferenceFieldUpdaterTest extends JSR166TestCase { |
15 |
|
volatile Integer x = null; |
16 |
|
Object z; |
37 |
|
updaterFor("y"); |
38 |
|
shouldThrow(); |
39 |
|
} catch (RuntimeException success) { |
40 |
< |
assertTrue(success.getCause() != null); |
40 |
> |
assertNotNull(success.getCause()); |
41 |
|
} |
42 |
|
} |
43 |
|
|
145 |
|
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a; |
146 |
|
a = updaterFor("x"); |
147 |
|
x = one; |
148 |
< |
while (!a.weakCompareAndSet(this, one, two)); |
149 |
< |
while (!a.weakCompareAndSet(this, two, m4)); |
148 |
> |
do {} while (!a.weakCompareAndSet(this, one, two)); |
149 |
> |
do {} while (!a.weakCompareAndSet(this, two, m4)); |
150 |
|
assertSame(m4, a.get(this)); |
151 |
< |
while (!a.weakCompareAndSet(this, m4, seven)); |
151 |
> |
do {} while (!a.weakCompareAndSet(this, m4, seven)); |
152 |
|
assertSame(seven, a.get(this)); |
153 |
|
} |
154 |
|
|