179 |
|
public FJException(Throwable cause) { super(cause); } |
180 |
|
} |
181 |
|
|
182 |
< |
// A simple recursive action for testing |
182 |
> |
/** A simple recursive action for testing. */ |
183 |
|
final class FibAction extends CheckedRecursiveAction { |
184 |
|
final int number; |
185 |
|
int result; |
197 |
|
} |
198 |
|
} |
199 |
|
|
200 |
< |
// A recursive action failing in base case |
200 |
> |
/** A recursive action failing in base case. */ |
201 |
|
static final class FailingFibAction extends RecursiveAction { |
202 |
|
final int number; |
203 |
|
int result; |
269 |
|
RecursiveAction a = new CheckedRecursiveAction() { |
270 |
|
protected void realCompute() { |
271 |
|
FibAction f = new FibAction(8); |
272 |
< |
final Thread myself = Thread.currentThread(); |
272 |
> |
final Thread currentThread = Thread.currentThread(); |
273 |
|
|
274 |
|
// test join() |
275 |
|
assertSame(f, f.fork()); |
276 |
< |
myself.interrupt(); |
277 |
< |
assertTrue(myself.isInterrupted()); |
276 |
> |
currentThread.interrupt(); |
277 |
|
assertNull(f.join()); |
278 |
|
Thread.interrupted(); |
279 |
|
assertEquals(21, f.result); |
282 |
|
f = new FibAction(8); |
283 |
|
f.cancel(true); |
284 |
|
assertSame(f, f.fork()); |
285 |
< |
myself.interrupt(); |
287 |
< |
assertTrue(myself.isInterrupted()); |
285 |
> |
currentThread.interrupt(); |
286 |
|
try { |
287 |
|
f.join(); |
288 |
|
shouldThrow(); |
294 |
|
f = new FibAction(8); |
295 |
|
f.completeExceptionally(new FJException()); |
296 |
|
assertSame(f, f.fork()); |
297 |
< |
myself.interrupt(); |
300 |
< |
assertTrue(myself.isInterrupted()); |
297 |
> |
currentThread.interrupt(); |
298 |
|
try { |
299 |
|
f.join(); |
300 |
|
shouldThrow(); |
306 |
|
// test quietlyJoin() |
307 |
|
f = new FibAction(8); |
308 |
|
assertSame(f, f.fork()); |
309 |
< |
myself.interrupt(); |
313 |
< |
assertTrue(myself.isInterrupted()); |
309 |
> |
currentThread.interrupt(); |
310 |
|
f.quietlyJoin(); |
311 |
|
Thread.interrupted(); |
312 |
|
assertEquals(21, f.result); |
315 |
|
f = new FibAction(8); |
316 |
|
f.cancel(true); |
317 |
|
assertSame(f, f.fork()); |
318 |
< |
myself.interrupt(); |
323 |
< |
assertTrue(myself.isInterrupted()); |
318 |
> |
currentThread.interrupt(); |
319 |
|
f.quietlyJoin(); |
320 |
|
Thread.interrupted(); |
321 |
|
checkCancelled(f); |
323 |
|
f = new FibAction(8); |
324 |
|
f.completeExceptionally(new FJException()); |
325 |
|
assertSame(f, f.fork()); |
326 |
< |
myself.interrupt(); |
332 |
< |
assertTrue(myself.isInterrupted()); |
326 |
> |
currentThread.interrupt(); |
327 |
|
f.quietlyJoin(); |
328 |
|
Thread.interrupted(); |
329 |
|
checkCompletedAbnormally(f, f.getException()); |
905 |
|
} |
906 |
|
} |
907 |
|
|
908 |
< |
// Version of CCF with forced failure in left completions |
908 |
> |
/** Version of CCF with forced failure in left completions. */ |
909 |
|
abstract static class FailingCCF extends CountedCompleter { |
910 |
|
int number; |
911 |
|
int rnumber; |