61 |
|
AtomicIntegerArray ai = new AtomicIntegerArray(SIZE); |
62 |
|
try { |
63 |
|
ai.get(SIZE); |
64 |
< |
} catch(IndexOutOfBoundsException success){ |
64 |
> |
} catch (IndexOutOfBoundsException success){ |
65 |
|
} |
66 |
|
try { |
67 |
|
ai.get(-1); |
68 |
< |
} catch(IndexOutOfBoundsException success){ |
68 |
> |
} catch (IndexOutOfBoundsException success){ |
69 |
|
} |
70 |
|
try { |
71 |
|
ai.set(SIZE, 0); |
72 |
< |
} catch(IndexOutOfBoundsException success){ |
72 |
> |
} catch (IndexOutOfBoundsException success){ |
73 |
|
} |
74 |
|
try { |
75 |
|
ai.set(-1, 0); |
76 |
< |
} catch(IndexOutOfBoundsException success){ |
76 |
> |
} catch (IndexOutOfBoundsException success){ |
77 |
|
} |
78 |
|
} |
79 |
|
|
133 |
|
a.set(0, 1); |
134 |
|
Thread t = new Thread(new Runnable() { |
135 |
|
public void run() { |
136 |
< |
while(!a.compareAndSet(0, 2, 3)) Thread.yield(); |
136 |
> |
while (!a.compareAndSet(0, 2, 3)) Thread.yield(); |
137 |
|
}}); |
138 |
|
try { |
139 |
|
t.start(); |
142 |
|
assertFalse(t.isAlive()); |
143 |
|
assertEquals(a.get(0), 3); |
144 |
|
} |
145 |
< |
catch(Exception e) { |
145 |
> |
catch (Exception e) { |
146 |
|
unexpectedException(); |
147 |
|
} |
148 |
|
} |
155 |
|
AtomicIntegerArray ai = new AtomicIntegerArray(SIZE); |
156 |
|
for (int i = 0; i < SIZE; ++i) { |
157 |
|
ai.set(i, 1); |
158 |
< |
while(!ai.weakCompareAndSet(i, 1,2)); |
159 |
< |
while(!ai.weakCompareAndSet(i, 2,-4)); |
158 |
> |
while (!ai.weakCompareAndSet(i, 1,2)); |
159 |
> |
while (!ai.weakCompareAndSet(i, 2,-4)); |
160 |
|
assertEquals(-4,ai.get(i)); |
161 |
< |
while(!ai.weakCompareAndSet(i, -4,7)); |
161 |
> |
while (!ai.weakCompareAndSet(i, -4,7)); |
162 |
|
assertEquals(7,ai.get(i)); |
163 |
|
} |
164 |
|
} |
308 |
|
t2.join(); |
309 |
|
assertEquals(c1.counts+c2.counts, SIZE * COUNTDOWN); |
310 |
|
} |
311 |
< |
catch(InterruptedException ie) { |
311 |
> |
catch (InterruptedException ie) { |
312 |
|
unexpectedException(); |
313 |
|
} |
314 |
|
} |
334 |
|
for (int i = 0; i < SIZE; ++i) { |
335 |
|
assertEquals(l.get(i), r.get(i)); |
336 |
|
} |
337 |
< |
} catch(Exception e){ |
337 |
> |
} catch (Exception e){ |
338 |
|
e.printStackTrace(); |
339 |
|
unexpectedException(); |
340 |
|
} |