453 |
|
/** |
454 |
|
* awaitAdvanceInterruptibly blocks interruptibly |
455 |
|
*/ |
456 |
< |
public void testAwaitAdvanceInterruptibly_interruptible() throws InterruptedException { |
456 |
> |
public void testAwaitAdvanceInterruptibly_Interruptible() throws InterruptedException { |
457 |
|
final Phaser phaser = new Phaser(1); |
458 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(2); |
459 |
|
|
478 |
|
public void realRun() throws TimeoutException { |
479 |
|
Thread.currentThread().interrupt(); |
480 |
|
try { |
481 |
< |
phaser.awaitAdvanceInterruptibly(0, 2*LONG_DELAY_MS, MILLISECONDS); |
481 |
> |
phaser.awaitAdvanceInterruptibly(0, randomTimeout(), randomTimeUnit()); |
482 |
|
shouldThrow(); |
483 |
|
} catch (InterruptedException success) {} |
484 |
|
assertFalse(Thread.interrupted()); |
485 |
|
|
486 |
|
pleaseInterrupt.countDown(); |
487 |
|
try { |
488 |
< |
phaser.awaitAdvanceInterruptibly(0, 2*LONG_DELAY_MS, MILLISECONDS); |
488 |
> |
phaser.awaitAdvanceInterruptibly(0, LONGER_DELAY_MS, MILLISECONDS); |
489 |
|
shouldThrow(); |
490 |
|
} catch (InterruptedException success) {} |
491 |
|
assertFalse(Thread.interrupted()); |
493 |
|
|
494 |
|
await(pleaseInterrupt); |
495 |
|
assertState(phaser, 0, 1, 1); |
496 |
< |
assertThreadsStayAlive(t1, t2); |
496 |
> |
if (randomBoolean()) assertThreadBlocks(t1, Thread.State.WAITING); |
497 |
> |
if (randomBoolean()) assertThreadBlocks(t2, Thread.State.TIMED_WAITING); |
498 |
|
t1.interrupt(); |
499 |
|
t2.interrupt(); |
500 |
|
awaitTermination(t1); |
524 |
|
}}); |
525 |
|
|
526 |
|
await(pleaseArrive); |
527 |
< |
waitForThreadToEnterWaitState(t); |
527 |
> |
assertThreadBlocks(t, Thread.State.WAITING); |
528 |
|
assertEquals(0, phaser.arrive()); |
529 |
|
awaitTermination(t); |
530 |
|
|
552 |
|
}}); |
553 |
|
|
554 |
|
await(pleaseArrive); |
555 |
< |
waitForThreadToEnterWaitState(t); |
555 |
> |
assertThreadBlocks(t, Thread.State.WAITING); |
556 |
|
t.interrupt(); |
557 |
|
assertEquals(0, phaser.arrive()); |
558 |
|
awaitTermination(t); |
581 |
|
}}); |
582 |
|
|
583 |
|
await(pleaseArrive); |
584 |
< |
waitForThreadToEnterWaitState(t); |
584 |
> |
assertThreadBlocks(t, Thread.State.WAITING); |
585 |
|
Thread.currentThread().interrupt(); |
586 |
|
assertEquals(1, phaser.arriveAndAwaitAdvance()); |
587 |
|
assertTrue(Thread.interrupted()); |
606 |
|
}}); |
607 |
|
|
608 |
|
await(pleaseInterrupt); |
609 |
< |
waitForThreadToEnterWaitState(t); |
609 |
> |
assertThreadBlocks(t, Thread.State.WAITING); |
610 |
|
t.interrupt(); |
611 |
|
Thread.currentThread().interrupt(); |
612 |
|
assertEquals(1, phaser.arriveAndAwaitAdvance()); |
781 |
|
assertEquals(THREADS, phaser.getArrivedParties()); |
782 |
|
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
783 |
|
for (Thread thread : threads) |
784 |
< |
waitForThreadToEnterWaitState(thread); |
784 |
> |
assertThreadBlocks(thread, Thread.State.WAITING); |
785 |
|
for (Thread thread : threads) |
786 |
|
assertTrue(thread.isAlive()); |
787 |
|
assertState(phaser, 0, THREADS + 1, 1); |