26 |
|
* Construction with non-existent field throws RuntimeException |
27 |
|
*/ |
28 |
|
public void testConstructor(){ |
29 |
< |
try{ |
29 |
> |
try { |
30 |
|
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> |
31 |
|
a = AtomicReferenceFieldUpdater.newUpdater |
32 |
|
(AtomicReferenceFieldUpdaterTest.class, Integer.class, "y"); |
40 |
|
* construction with field not of given type throws RuntimeException |
41 |
|
*/ |
42 |
|
public void testConstructor2(){ |
43 |
< |
try{ |
43 |
> |
try { |
44 |
|
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> |
45 |
|
a = AtomicReferenceFieldUpdater.newUpdater |
46 |
|
(AtomicReferenceFieldUpdaterTest.class, Integer.class, "z"); |
53 |
|
* Constructor with non-volatile field throws exception |
54 |
|
*/ |
55 |
|
public void testConstructor3(){ |
56 |
< |
try{ |
56 |
> |
try { |
57 |
|
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> |
58 |
|
a = AtomicReferenceFieldUpdater.newUpdater |
59 |
|
(AtomicReferenceFieldUpdaterTest.class, Integer.class, "w"); |
133 |
|
|
134 |
|
Thread t = new Thread(new Runnable() { |
135 |
|
public void run() { |
136 |
< |
while(!a.compareAndSet(AtomicReferenceFieldUpdaterTest.this, two, three)) Thread.yield(); |
136 |
> |
while (!a.compareAndSet(AtomicReferenceFieldUpdaterTest.this, two, three)) Thread.yield(); |
137 |
|
}}); |
138 |
|
try { |
139 |
|
t.start(); |
142 |
|
assertFalse(t.isAlive()); |
143 |
|
assertEquals(a.get(this), three); |
144 |
|
} |
145 |
< |
catch(Exception e) { |
145 |
> |
catch (Exception e) { |
146 |
|
unexpectedException(); |
147 |
|
} |
148 |
|
} |
159 |
|
return; |
160 |
|
} |
161 |
|
x = one; |
162 |
< |
while(!a.weakCompareAndSet(this,one,two)); |
163 |
< |
while(!a.weakCompareAndSet(this,two,m4)); |
162 |
> |
while (!a.weakCompareAndSet(this,one,two)); |
163 |
> |
while (!a.weakCompareAndSet(this,two,m4)); |
164 |
|
assertEquals(m4,a.get(this)); |
165 |
< |
while(!a.weakCompareAndSet(this,m4,seven)); |
165 |
> |
while (!a.weakCompareAndSet(this,m4,seven)); |
166 |
|
assertEquals(seven,a.get(this)); |
167 |
|
} |
168 |
|
|