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