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 |
> |
assertTrue(currentThread.isInterrupted()); |
267 |
|
assertNull(f.join()); |
268 |
|
Thread.interrupted(); |
269 |
|
assertEquals(21, f.result); |
272 |
|
f = new FibAction(8); |
273 |
|
f.cancel(true); |
274 |
|
assertSame(f, f.fork()); |
275 |
< |
myself.interrupt(); |
276 |
< |
assertTrue(myself.isInterrupted()); |
275 |
> |
currentThread.interrupt(); |
276 |
> |
assertTrue(currentThread.isInterrupted()); |
277 |
|
try { |
278 |
|
f.join(); |
279 |
|
shouldThrow(); |
285 |
|
f = new FibAction(8); |
286 |
|
f.completeExceptionally(new FJException()); |
287 |
|
assertSame(f, f.fork()); |
288 |
< |
myself.interrupt(); |
289 |
< |
assertTrue(myself.isInterrupted()); |
288 |
> |
currentThread.interrupt(); |
289 |
> |
assertTrue(currentThread.isInterrupted()); |
290 |
|
try { |
291 |
|
f.join(); |
292 |
|
shouldThrow(); |
298 |
|
// test quietlyJoin() |
299 |
|
f = new FibAction(8); |
300 |
|
assertSame(f, f.fork()); |
301 |
< |
myself.interrupt(); |
302 |
< |
assertTrue(myself.isInterrupted()); |
301 |
> |
currentThread.interrupt(); |
302 |
> |
assertTrue(currentThread.isInterrupted()); |
303 |
|
f.quietlyJoin(); |
304 |
|
Thread.interrupted(); |
305 |
|
assertEquals(21, f.result); |
308 |
|
f = new FibAction(8); |
309 |
|
f.cancel(true); |
310 |
|
assertSame(f, f.fork()); |
311 |
< |
myself.interrupt(); |
312 |
< |
assertTrue(myself.isInterrupted()); |
311 |
> |
currentThread.interrupt(); |
312 |
> |
assertTrue(currentThread.isInterrupted()); |
313 |
|
f.quietlyJoin(); |
314 |
|
Thread.interrupted(); |
315 |
|
checkCancelled(f); |
317 |
|
f = new FibAction(8); |
318 |
|
f.completeExceptionally(new FJException()); |
319 |
|
assertSame(f, f.fork()); |
320 |
< |
myself.interrupt(); |
321 |
< |
assertTrue(myself.isInterrupted()); |
320 |
> |
currentThread.interrupt(); |
321 |
> |
assertTrue(currentThread.isInterrupted()); |
322 |
|
f.quietlyJoin(); |
323 |
|
Thread.interrupted(); |
324 |
|
checkCompletedAbnormally(f, f.getException()); |
358 |
|
public void realRun() throws InterruptedException { |
359 |
|
FibAction[] fibActions = sq.take(); |
360 |
|
FibAction f; |
361 |
< |
final Thread myself = Thread.currentThread(); |
361 |
> |
final Thread currentThread = Thread.currentThread(); |
362 |
|
|
363 |
|
// test join() ------------ |
364 |
|
|
365 |
|
f = fibActions[0]; |
366 |
|
assertFalse(ForkJoinTask.inForkJoinPool()); |
367 |
< |
myself.interrupt(); |
368 |
< |
assertTrue(myself.isInterrupted()); |
367 |
> |
currentThread.interrupt(); |
368 |
> |
assertTrue(currentThread.isInterrupted()); |
369 |
|
assertNull(f.join()); |
370 |
|
assertTrue(Thread.interrupted()); |
371 |
|
assertEquals(21, f.result); |
372 |
|
checkCompletedNormally(f); |
373 |
|
|
374 |
|
f = fibActions[1]; |
375 |
< |
myself.interrupt(); |
376 |
< |
assertTrue(myself.isInterrupted()); |
375 |
> |
currentThread.interrupt(); |
376 |
> |
assertTrue(currentThread.isInterrupted()); |
377 |
|
try { |
378 |
|
f.join(); |
379 |
|
shouldThrow(); |
383 |
|
} |
384 |
|
|
385 |
|
f = fibActions[2]; |
386 |
< |
myself.interrupt(); |
387 |
< |
assertTrue(myself.isInterrupted()); |
386 |
> |
currentThread.interrupt(); |
387 |
> |
assertTrue(currentThread.isInterrupted()); |
388 |
|
try { |
389 |
|
f.join(); |
390 |
|
shouldThrow(); |
396 |
|
// test quietlyJoin() --------- |
397 |
|
|
398 |
|
f = fibActions[3]; |
399 |
< |
myself.interrupt(); |
400 |
< |
assertTrue(myself.isInterrupted()); |
399 |
> |
currentThread.interrupt(); |
400 |
> |
assertTrue(currentThread.isInterrupted()); |
401 |
|
f.quietlyJoin(); |
402 |
|
assertTrue(Thread.interrupted()); |
403 |
|
assertEquals(21, f.result); |
404 |
|
checkCompletedNormally(f); |
405 |
|
|
406 |
|
f = fibActions[4]; |
407 |
< |
myself.interrupt(); |
408 |
< |
assertTrue(myself.isInterrupted()); |
407 |
> |
currentThread.interrupt(); |
408 |
> |
assertTrue(currentThread.isInterrupted()); |
409 |
|
f.quietlyJoin(); |
410 |
|
assertTrue(Thread.interrupted()); |
411 |
|
checkCancelled(f); |
412 |
|
|
413 |
|
f = fibActions[5]; |
414 |
< |
myself.interrupt(); |
415 |
< |
assertTrue(myself.isInterrupted()); |
414 |
> |
currentThread.interrupt(); |
415 |
> |
assertTrue(currentThread.isInterrupted()); |
416 |
|
f.quietlyJoin(); |
417 |
|
assertTrue(Thread.interrupted()); |
418 |
|
assertTrue(f.getException() instanceof FJException); |