25 |
|
* Construction with non-existent field throws RuntimeException |
26 |
|
*/ |
27 |
|
public void testConstructor() { |
28 |
< |
try{ |
28 |
> |
try { |
29 |
|
AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> |
30 |
|
a = AtomicIntegerFieldUpdater.newUpdater |
31 |
|
(AtomicIntegerFieldUpdaterTest.class, "y"); |
38 |
|
* construction with field not of given type throws RuntimeException |
39 |
|
*/ |
40 |
|
public void testConstructor2() { |
41 |
< |
try{ |
41 |
> |
try { |
42 |
|
AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> |
43 |
|
a = AtomicIntegerFieldUpdater.newUpdater |
44 |
|
(AtomicIntegerFieldUpdaterTest.class, "z"); |
51 |
|
* construction with non-volatile field throws RuntimeException |
52 |
|
*/ |
53 |
|
public void testConstructor3() { |
54 |
< |
try{ |
54 |
> |
try { |
55 |
|
AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> |
56 |
|
a = AtomicIntegerFieldUpdater.newUpdater |
57 |
|
(AtomicIntegerFieldUpdaterTest.class, "w"); |
134 |
|
|
135 |
|
Thread t = new Thread(new Runnable() { |
136 |
|
public void run() { |
137 |
< |
while(!a.compareAndSet(AtomicIntegerFieldUpdaterTest.this, 2, 3)) Thread.yield(); |
137 |
> |
while (!a.compareAndSet(AtomicIntegerFieldUpdaterTest.this, 2, 3)) Thread.yield(); |
138 |
|
}}); |
139 |
|
try { |
140 |
|
t.start(); |
143 |
|
assertFalse(t.isAlive()); |
144 |
|
assertEquals(a.get(this), 3); |
145 |
|
} |
146 |
< |
catch(Exception e) { |
146 |
> |
catch (Exception e) { |
147 |
|
unexpectedException(); |
148 |
|
} |
149 |
|
} |
160 |
|
return; |
161 |
|
} |
162 |
|
x = 1; |
163 |
< |
while(!a.weakCompareAndSet(this,1,2)); |
164 |
< |
while(!a.weakCompareAndSet(this,2,-4)); |
163 |
> |
while (!a.weakCompareAndSet(this,1,2)); |
164 |
> |
while (!a.weakCompareAndSet(this,2,-4)); |
165 |
|
assertEquals(-4,a.get(this)); |
166 |
< |
while(!a.weakCompareAndSet(this,-4,7)); |
166 |
> |
while (!a.weakCompareAndSet(this,-4,7)); |
167 |
|
assertEquals(7,a.get(this)); |
168 |
|
} |
169 |
|
|