95 |
|
*/ |
96 |
|
public void testCompareAndSetInMultipleThreads() throws Exception { |
97 |
|
final AtomicMarkableReference ai = new AtomicMarkableReference(one, false); |
98 |
< |
Thread t = new Thread(new Runnable() { |
99 |
< |
public void run() { |
100 |
< |
while (!ai.compareAndSet(two, three, false, false)) Thread.yield(); |
101 |
< |
}}); |
98 |
> |
Thread t = new Thread(new CheckedRunnable() { |
99 |
> |
public void realRun() { |
100 |
> |
while (!ai.compareAndSet(two, three, false, false)) |
101 |
> |
Thread.yield(); |
102 |
> |
}}); |
103 |
|
|
104 |
|
t.start(); |
105 |
|
assertTrue(ai.compareAndSet(one, two, false, false)); |
115 |
|
*/ |
116 |
|
public void testCompareAndSetInMultipleThreads2() throws Exception { |
117 |
|
final AtomicMarkableReference ai = new AtomicMarkableReference(one, false); |
118 |
< |
Thread t = new Thread(new Runnable() { |
119 |
< |
public void run() { |
120 |
< |
while (!ai.compareAndSet(one, one, true, false)) Thread.yield(); |
121 |
< |
}}); |
118 |
> |
Thread t = new Thread(new CheckedRunnable() { |
119 |
> |
public void realRun() { |
120 |
> |
while (!ai.compareAndSet(one, one, true, false)) |
121 |
> |
Thread.yield(); |
122 |
> |
}}); |
123 |
|
|
124 |
|
t.start(); |
125 |
|
assertTrue(ai.compareAndSet(one, one, false, true)); |