168 |
|
public FJException(Throwable cause) { super(cause); } |
169 |
|
} |
170 |
|
|
171 |
< |
// A simple recursive action for testing |
171 |
> |
/** A simple recursive action for testing. */ |
172 |
|
final class FibAction extends CheckedRecursiveAction { |
173 |
|
final int number; |
174 |
|
int result; |
186 |
|
} |
187 |
|
} |
188 |
|
|
189 |
< |
// A recursive action failing in base case |
189 |
> |
/** A recursive action failing in base case. */ |
190 |
|
static final class FailingFibAction extends RecursiveAction { |
191 |
|
final int number; |
192 |
|
int result; |
258 |
|
RecursiveAction a = new CheckedRecursiveAction() { |
259 |
|
protected void realCompute() { |
260 |
|
FibAction f = new FibAction(8); |
261 |
< |
final Thread myself = Thread.currentThread(); |
261 |
> |
final Thread currentThread = Thread.currentThread(); |
262 |
|
|
263 |
|
// test join() |
264 |
|
assertSame(f, f.fork()); |
265 |
< |
myself.interrupt(); |
266 |
< |
assertTrue(myself.isInterrupted()); |
265 |
> |
currentThread.interrupt(); |
266 |
|
assertNull(f.join()); |
267 |
|
Thread.interrupted(); |
268 |
|
assertEquals(21, f.result); |
271 |
|
f = new FibAction(8); |
272 |
|
f.cancel(true); |
273 |
|
assertSame(f, f.fork()); |
274 |
< |
myself.interrupt(); |
276 |
< |
assertTrue(myself.isInterrupted()); |
274 |
> |
currentThread.interrupt(); |
275 |
|
try { |
276 |
|
f.join(); |
277 |
|
shouldThrow(); |
283 |
|
f = new FibAction(8); |
284 |
|
f.completeExceptionally(new FJException()); |
285 |
|
assertSame(f, f.fork()); |
286 |
< |
myself.interrupt(); |
289 |
< |
assertTrue(myself.isInterrupted()); |
286 |
> |
currentThread.interrupt(); |
287 |
|
try { |
288 |
|
f.join(); |
289 |
|
shouldThrow(); |
295 |
|
// test quietlyJoin() |
296 |
|
f = new FibAction(8); |
297 |
|
assertSame(f, f.fork()); |
298 |
< |
myself.interrupt(); |
302 |
< |
assertTrue(myself.isInterrupted()); |
298 |
> |
currentThread.interrupt(); |
299 |
|
f.quietlyJoin(); |
300 |
|
Thread.interrupted(); |
301 |
|
assertEquals(21, f.result); |
304 |
|
f = new FibAction(8); |
305 |
|
f.cancel(true); |
306 |
|
assertSame(f, f.fork()); |
307 |
< |
myself.interrupt(); |
312 |
< |
assertTrue(myself.isInterrupted()); |
307 |
> |
currentThread.interrupt(); |
308 |
|
f.quietlyJoin(); |
309 |
|
Thread.interrupted(); |
310 |
|
checkCancelled(f); |
312 |
|
f = new FibAction(8); |
313 |
|
f.completeExceptionally(new FJException()); |
314 |
|
assertSame(f, f.fork()); |
315 |
< |
myself.interrupt(); |
321 |
< |
assertTrue(myself.isInterrupted()); |
315 |
> |
currentThread.interrupt(); |
316 |
|
f.quietlyJoin(); |
317 |
|
Thread.interrupted(); |
318 |
|
checkCompletedAbnormally(f, f.getException()); |
352 |
|
public void realRun() throws InterruptedException { |
353 |
|
FibAction[] fibActions = sq.take(); |
354 |
|
FibAction f; |
355 |
< |
final Thread myself = Thread.currentThread(); |
355 |
> |
final Thread currentThread = Thread.currentThread(); |
356 |
|
|
357 |
|
// test join() ------------ |
358 |
|
|
359 |
|
f = fibActions[0]; |
360 |
|
assertFalse(ForkJoinTask.inForkJoinPool()); |
361 |
< |
myself.interrupt(); |
368 |
< |
assertTrue(myself.isInterrupted()); |
361 |
> |
currentThread.interrupt(); |
362 |
|
assertNull(f.join()); |
363 |
|
assertTrue(Thread.interrupted()); |
364 |
|
assertEquals(21, f.result); |
365 |
|
checkCompletedNormally(f); |
366 |
|
|
367 |
|
f = fibActions[1]; |
368 |
< |
myself.interrupt(); |
376 |
< |
assertTrue(myself.isInterrupted()); |
368 |
> |
currentThread.interrupt(); |
369 |
|
try { |
370 |
|
f.join(); |
371 |
|
shouldThrow(); |
375 |
|
} |
376 |
|
|
377 |
|
f = fibActions[2]; |
378 |
< |
myself.interrupt(); |
387 |
< |
assertTrue(myself.isInterrupted()); |
378 |
> |
currentThread.interrupt(); |
379 |
|
try { |
380 |
|
f.join(); |
381 |
|
shouldThrow(); |
387 |
|
// test quietlyJoin() --------- |
388 |
|
|
389 |
|
f = fibActions[3]; |
390 |
< |
myself.interrupt(); |
400 |
< |
assertTrue(myself.isInterrupted()); |
390 |
> |
currentThread.interrupt(); |
391 |
|
f.quietlyJoin(); |
392 |
|
assertTrue(Thread.interrupted()); |
393 |
|
assertEquals(21, f.result); |
394 |
|
checkCompletedNormally(f); |
395 |
|
|
396 |
|
f = fibActions[4]; |
397 |
< |
myself.interrupt(); |
408 |
< |
assertTrue(myself.isInterrupted()); |
397 |
> |
currentThread.interrupt(); |
398 |
|
f.quietlyJoin(); |
399 |
|
assertTrue(Thread.interrupted()); |
400 |
|
checkCancelled(f); |
401 |
|
|
402 |
|
f = fibActions[5]; |
403 |
< |
myself.interrupt(); |
415 |
< |
assertTrue(myself.isInterrupted()); |
403 |
> |
currentThread.interrupt(); |
404 |
|
f.quietlyJoin(); |
405 |
|
assertTrue(Thread.interrupted()); |
406 |
|
assertTrue(f.getException() instanceof FJException); |