138 |
|
if (mayInterruptIfRunning) { |
139 |
|
if (!UNSAFE.compareAndSwapInt(this, stateOffset, NEW, INTERRUPTING)) |
140 |
|
return false; |
141 |
< |
Thread t = runner; |
142 |
< |
if (t != null) |
143 |
< |
t.interrupt(); |
144 |
< |
UNSAFE.putOrderedInt(this, stateOffset, INTERRUPTED); // final state |
141 |
> |
try { // in case call to interrupt throws exception |
142 |
> |
Thread t = runner; |
143 |
> |
if (t != null) |
144 |
> |
t.interrupt(); |
145 |
> |
} finally { // final state |
146 |
> |
UNSAFE.putOrderedInt(this, stateOffset, INTERRUPTED); |
147 |
> |
} |
148 |
|
} |
149 |
|
else if (!UNSAFE.compareAndSwapInt(this, stateOffset, NEW, CANCELLED)) |
150 |
|
return false; |