--- jsr166/src/test/tck/JSR166TestCase.java 2016/07/27 17:16:23 1.198 +++ jsr166/src/test/tck/JSR166TestCase.java 2016/08/10 01:28:14 1.200 @@ -41,6 +41,7 @@ import java.security.ProtectionDomain; import java.security.SecurityPermission; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Date; import java.util.Enumeration; import java.util.Iterator; @@ -62,6 +63,7 @@ import java.util.concurrent.RejectedExec import java.util.concurrent.Semaphore; import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; @@ -1251,7 +1253,7 @@ public class JSR166TestCase extends Test * thread to enter a wait state: BLOCKED, WAITING, or TIMED_WAITING. */ void waitForThreadToEnterWaitState(Thread thread, long timeoutMillis) { - long startTime = System.nanoTime(); + long startTime = 0L; for (;;) { Thread.State s = thread.getState(); if (s == Thread.State.BLOCKED || @@ -1260,6 +1262,8 @@ public class JSR166TestCase extends Test return; else if (s == Thread.State.TERMINATED) fail("Unexpected thread termination"); + else if (startTime == 0L) + startTime = System.nanoTime(); else if (millisElapsedSince(startTime) > timeoutMillis) { threadAssertTrue(thread.isAlive()); return; @@ -1873,4 +1877,7 @@ public class JSR166TestCase extends Test 1000L, MILLISECONDS, new SynchronousQueue()); + static void shuffle(T[] array) { + Collections.shuffle(Arrays.asList(array), ThreadLocalRandom.current()); + } }