--- jsr166/src/test/tck/BlockingQueueTest.java 2018/06/22 00:04:58 1.22 +++ jsr166/src/test/tck/BlockingQueueTest.java 2019/08/11 22:29:26 1.23 @@ -226,7 +226,7 @@ public abstract class BlockingQueueTest Thread.currentThread().interrupt(); try { - q.poll(LONG_DELAY_MS, MILLISECONDS); + q.poll(randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); @@ -247,7 +247,7 @@ public abstract class BlockingQueueTest assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); barrier.await(); - assertThreadBlocks(t, Thread.State.TIMED_WAITING); + if (randomBoolean()) assertThreadBlocks(t, Thread.State.TIMED_WAITING); t.interrupt(); awaitTermination(t); } @@ -269,7 +269,7 @@ public abstract class BlockingQueueTest }}); await(threadStarted); - assertThreadBlocks(t, Thread.State.WAITING); + if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); t.interrupt(); awaitTermination(t); } @@ -302,15 +302,19 @@ public abstract class BlockingQueueTest Thread t = newStartedThread(new CheckedRunnable() { public void realRun() { threadStarted.countDown(); + long startTime = System.nanoTime(); + try { - q.poll(2 * LONG_DELAY_MS, MILLISECONDS); + q.poll(LONG_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); + + assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); }}); await(threadStarted); - assertThreadBlocks(t, Thread.State.TIMED_WAITING); + if (randomBoolean()) assertThreadBlocks(t, Thread.State.TIMED_WAITING); t.interrupt(); awaitTermination(t); } @@ -323,12 +327,16 @@ public abstract class BlockingQueueTest final BlockingQueue q = emptyCollection(); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() { + long startTime = System.nanoTime(); + Thread.currentThread().interrupt(); try { - q.poll(2 * LONG_DELAY_MS, MILLISECONDS); + q.poll(LONG_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (InterruptedException success) {} assertFalse(Thread.interrupted()); + + assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); }}); awaitTermination(t);