59 |
|
AtomicLongArray ai = new AtomicLongArray(SIZE); |
60 |
|
try { |
61 |
|
ai.get(SIZE); |
62 |
< |
} catch(IndexOutOfBoundsException success){ |
62 |
> |
} catch (IndexOutOfBoundsException success){ |
63 |
|
} |
64 |
|
try { |
65 |
|
ai.get(-1); |
66 |
< |
} catch(IndexOutOfBoundsException success){ |
66 |
> |
} catch (IndexOutOfBoundsException success){ |
67 |
|
} |
68 |
|
try { |
69 |
|
ai.set(SIZE, 0); |
70 |
< |
} catch(IndexOutOfBoundsException success){ |
70 |
> |
} catch (IndexOutOfBoundsException success){ |
71 |
|
} |
72 |
|
try { |
73 |
|
ai.set(-1, 0); |
74 |
< |
} catch(IndexOutOfBoundsException success){ |
74 |
> |
} catch (IndexOutOfBoundsException success){ |
75 |
|
} |
76 |
|
} |
77 |
|
|
131 |
|
a.set(0, 1); |
132 |
|
Thread t = new Thread(new Runnable() { |
133 |
|
public void run() { |
134 |
< |
while(!a.compareAndSet(0, 2, 3)) Thread.yield(); |
134 |
> |
while (!a.compareAndSet(0, 2, 3)) Thread.yield(); |
135 |
|
}}); |
136 |
|
try { |
137 |
|
t.start(); |
140 |
|
assertFalse(t.isAlive()); |
141 |
|
assertEquals(a.get(0), 3); |
142 |
|
} |
143 |
< |
catch(Exception e) { |
143 |
> |
catch (Exception e) { |
144 |
|
unexpectedException(); |
145 |
|
} |
146 |
|
} |
153 |
|
AtomicLongArray ai = new AtomicLongArray(SIZE); |
154 |
|
for (int i = 0; i < SIZE; ++i) { |
155 |
|
ai.set(i, 1); |
156 |
< |
while(!ai.weakCompareAndSet(i, 1,2)); |
157 |
< |
while(!ai.weakCompareAndSet(i, 2,-4)); |
156 |
> |
while (!ai.weakCompareAndSet(i, 1,2)); |
157 |
> |
while (!ai.weakCompareAndSet(i, 2,-4)); |
158 |
|
assertEquals(-4,ai.get(i)); |
159 |
< |
while(!ai.weakCompareAndSet(i, -4,7)); |
159 |
> |
while (!ai.weakCompareAndSet(i, -4,7)); |
160 |
|
assertEquals(7,ai.get(i)); |
161 |
|
} |
162 |
|
} |
306 |
|
t2.join(); |
307 |
|
assertEquals(c1.counts+c2.counts, SIZE * COUNTDOWN); |
308 |
|
} |
309 |
< |
catch(InterruptedException ie) { |
309 |
> |
catch (InterruptedException ie) { |
310 |
|
unexpectedException(); |
311 |
|
} |
312 |
|
} |
331 |
|
for (int i = 0; i < SIZE; ++i) { |
332 |
|
assertEquals(l.get(i), r.get(i)); |
333 |
|
} |
334 |
< |
} catch(Exception e){ |
334 |
> |
} catch (Exception e){ |
335 |
|
unexpectedException(); |
336 |
|
} |
337 |
|
} |