135 |
|
} |
136 |
|
|
137 |
|
/** |
138 |
+ |
* repeated weakCompareAndSetPlain succeeds in changing value when equal |
139 |
+ |
* to expected |
140 |
+ |
*/ |
141 |
+ |
public void testWeakCompareAndSetPlain() { |
142 |
+ |
AtomicBoolean ai = new AtomicBoolean(true); |
143 |
+ |
do {} while (!ai.weakCompareAndSetPlain(true, false)); |
144 |
+ |
do {} while (!ai.weakCompareAndSetPlain(false, false)); |
145 |
+ |
assertFalse(ai.get()); |
146 |
+ |
do {} while (!ai.weakCompareAndSetPlain(false, true)); |
147 |
+ |
assertTrue(ai.get()); |
148 |
+ |
} |
149 |
+ |
|
150 |
+ |
/** |
151 |
|
* repeated weakCompareAndSetVolatile succeeds in changing value when equal |
152 |
|
* to expected |
153 |
|
*/ |