< prev index next >

test/jdk/java/util/concurrent/tck/PhaserTest.java

Print this page
8225490: Miscellaneous changes imported from jsr166 CVS 2019-09
Reviewed-by: martin, alanb

*** 478,488 **** } /** * awaitAdvanceInterruptibly blocks interruptibly */ ! public void testAwaitAdvanceInterruptibly_interruptible() throws InterruptedException { final Phaser phaser = new Phaser(1); final CountDownLatch pleaseInterrupt = new CountDownLatch(2); Thread t1 = newStartedThread(new CheckedRunnable() { public void realRun() { --- 478,488 ---- } /** * awaitAdvanceInterruptibly blocks interruptibly */ ! public void testAwaitAdvanceInterruptibly_Interruptible() throws InterruptedException { final Phaser phaser = new Phaser(1); final CountDownLatch pleaseInterrupt = new CountDownLatch(2); Thread t1 = newStartedThread(new CheckedRunnable() { public void realRun() {
*** 503,529 **** Thread t2 = newStartedThread(new CheckedRunnable() { public void realRun() throws TimeoutException { Thread.currentThread().interrupt(); try { ! phaser.awaitAdvanceInterruptibly(0, 2*LONG_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { ! phaser.awaitAdvanceInterruptibly(0, 2*LONG_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); }}); await(pleaseInterrupt); assertState(phaser, 0, 1, 1); ! assertThreadBlocks(t1, Thread.State.WAITING); ! assertThreadBlocks(t2, Thread.State.TIMED_WAITING); t1.interrupt(); t2.interrupt(); awaitTermination(t1); awaitTermination(t2); assertState(phaser, 0, 1, 1); --- 503,529 ---- Thread t2 = newStartedThread(new CheckedRunnable() { public void realRun() throws TimeoutException { Thread.currentThread().interrupt(); try { ! phaser.awaitAdvanceInterruptibly(0, randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); pleaseInterrupt.countDown(); try { ! phaser.awaitAdvanceInterruptibly(0, LONGER_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); }}); await(pleaseInterrupt); assertState(phaser, 0, 1, 1); ! if (randomBoolean()) assertThreadBlocks(t1, Thread.State.WAITING); ! if (randomBoolean()) assertThreadBlocks(t2, Thread.State.TIMED_WAITING); t1.interrupt(); t2.interrupt(); awaitTermination(t1); awaitTermination(t2); assertState(phaser, 0, 1, 1);
< prev index next >