62 |
|
AtomicReferenceArray<Integer> ai = new AtomicReferenceArray<Integer>(SIZE); |
63 |
|
try { |
64 |
|
ai.get(SIZE); |
65 |
< |
} catch(IndexOutOfBoundsException success){ |
65 |
> |
} catch (IndexOutOfBoundsException success){ |
66 |
|
} |
67 |
|
try { |
68 |
|
ai.get(-1); |
69 |
< |
} catch(IndexOutOfBoundsException success){ |
69 |
> |
} catch (IndexOutOfBoundsException success){ |
70 |
|
} |
71 |
|
try { |
72 |
|
ai.set(SIZE, null); |
73 |
< |
} catch(IndexOutOfBoundsException success){ |
73 |
> |
} catch (IndexOutOfBoundsException success){ |
74 |
|
} |
75 |
|
try { |
76 |
|
ai.set(-1, null); |
77 |
< |
} catch(IndexOutOfBoundsException success){ |
77 |
> |
} catch (IndexOutOfBoundsException success){ |
78 |
|
} |
79 |
|
} |
80 |
|
|
134 |
|
a.set(0, one); |
135 |
|
Thread t = new Thread(new Runnable() { |
136 |
|
public void run() { |
137 |
< |
while(!a.compareAndSet(0, two, three)) Thread.yield(); |
137 |
> |
while (!a.compareAndSet(0, two, three)) Thread.yield(); |
138 |
|
}}); |
139 |
|
try { |
140 |
|
t.start(); |
143 |
|
assertFalse(t.isAlive()); |
144 |
|
assertEquals(a.get(0), three); |
145 |
|
} |
146 |
< |
catch(Exception e) { |
146 |
> |
catch (Exception e) { |
147 |
|
unexpectedException(); |
148 |
|
} |
149 |
|
} |
156 |
|
AtomicReferenceArray ai = new AtomicReferenceArray(SIZE); |
157 |
|
for (int i = 0; i < SIZE; ++i) { |
158 |
|
ai.set(i, one); |
159 |
< |
while(!ai.weakCompareAndSet(i, one,two)); |
160 |
< |
while(!ai.weakCompareAndSet(i, two,m4)); |
159 |
> |
while (!ai.weakCompareAndSet(i, one,two)); |
160 |
> |
while (!ai.weakCompareAndSet(i, two,m4)); |
161 |
|
assertEquals(m4,ai.get(i)); |
162 |
< |
while(!ai.weakCompareAndSet(i, m4,seven)); |
162 |
> |
while (!ai.weakCompareAndSet(i, m4,seven)); |
163 |
|
assertEquals(seven,ai.get(i)); |
164 |
|
} |
165 |
|
} |
199 |
|
for (int i = 0; i < SIZE; ++i) { |
200 |
|
assertEquals(r.get(i), l.get(i)); |
201 |
|
} |
202 |
< |
} catch(Exception e){ |
202 |
> |
} catch (Exception e){ |
203 |
|
unexpectedException(); |
204 |
|
} |
205 |
|
} |