122 |
|
* compareAndSet in one thread enables another waiting for value |
123 |
|
* to succeed |
124 |
|
*/ |
125 |
< |
public void testCompareAndSetInMultipleThreads() { |
125 |
> |
public void testCompareAndSetInMultipleThreads() throws Exception { |
126 |
|
x = one; |
127 |
|
final AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a; |
128 |
|
try { |
135 |
|
public void run() { |
136 |
|
while (!a.compareAndSet(AtomicReferenceFieldUpdaterTest.this, two, three)) Thread.yield(); |
137 |
|
}}); |
138 |
< |
try { |
139 |
< |
t.start(); |
140 |
< |
assertTrue(a.compareAndSet(this, one, two)); |
141 |
< |
t.join(LONG_DELAY_MS); |
142 |
< |
assertFalse(t.isAlive()); |
143 |
< |
assertEquals(a.get(this), three); |
144 |
< |
} |
145 |
< |
catch (Exception e) { |
146 |
< |
unexpectedException(); |
147 |
< |
} |
138 |
> |
|
139 |
> |
t.start(); |
140 |
> |
assertTrue(a.compareAndSet(this, one, two)); |
141 |
> |
t.join(LONG_DELAY_MS); |
142 |
> |
assertFalse(t.isAlive()); |
143 |
> |
assertEquals(a.get(this), three); |
144 |
|
} |
145 |
|
|
146 |
|
/** |