112 |
|
*/ |
113 |
|
public void testCompareAndSetInMultipleThreads() throws Exception { |
114 |
|
final AtomicDouble at = new AtomicDouble(1.0); |
115 |
< |
Thread t = new Thread(new CheckedRunnable() { |
115 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
116 |
|
public void realRun() { |
117 |
|
while (!at.compareAndSet(2.0, 3.0)) |
118 |
|
Thread.yield(); |
119 |
|
}}); |
120 |
|
|
121 |
– |
t.start(); |
121 |
|
assertTrue(at.compareAndSet(1.0, 2.0)); |
122 |
< |
t.join(LONG_DELAY_MS); |
124 |
< |
assertFalse(t.isAlive()); |
122 |
> |
awaitTermination(t); |
123 |
|
assertBitEquals(3.0, at.get()); |
124 |
|
} |
125 |
|
|