6 |
|
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
8 |
|
|
9 |
– |
import junit.framework.*; |
9 |
|
import java.util.concurrent.atomic.AtomicLongFieldUpdater; |
10 |
|
|
11 |
+ |
import junit.framework.Test; |
12 |
+ |
import junit.framework.TestSuite; |
13 |
+ |
|
14 |
|
public class AtomicLongFieldUpdaterTest extends JSR166TestCase { |
15 |
|
volatile long x = 0; |
16 |
|
int z; |
134 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a; |
135 |
|
a = updaterFor("x"); |
136 |
|
x = 1; |
137 |
< |
while (!a.weakCompareAndSet(this, 1, 2)); |
138 |
< |
while (!a.weakCompareAndSet(this, 2, -4)); |
137 |
> |
do {} while (!a.weakCompareAndSet(this, 1, 2)); |
138 |
> |
do {} while (!a.weakCompareAndSet(this, 2, -4)); |
139 |
|
assertEquals(-4, a.get(this)); |
140 |
< |
while (!a.weakCompareAndSet(this, -4, 7)); |
140 |
> |
do {} while (!a.weakCompareAndSet(this, -4, 7)); |
141 |
|
assertEquals(7, a.get(this)); |
142 |
|
} |
143 |
|
|