--- jsr166/src/test/tck/JSR166TestCase.java 2011/05/06 11:22:07 1.76 +++ jsr166/src/test/tck/JSR166TestCase.java 2011/05/07 19:03:26 1.78 @@ -449,7 +449,7 @@ public class JSR166TestCase extends Test */ public static void delay(long ms) throws InterruptedException { long startTime = System.nanoTime(); - long ns = ms * 1000 * 1000; + long ns = ms * 1000 * 1000; for (;;) { if (ms > 0L) Thread.sleep(ms); @@ -457,7 +457,7 @@ public class JSR166TestCase extends Test Thread.yield(); long d = ns - (System.nanoTime() - startTime); if (d > 0L) - ms = d / (1000 * 1000); + ms = d / (1000 * 1000); else break; } @@ -478,6 +478,20 @@ public class JSR166TestCase extends Test } } + /** + * Checks that thread does not terminate within timeoutMillis + * milliseconds (that is, Thread.join times out). + */ + public void assertThreadJoinTimesOut(Thread thread, long timeoutMillis) { + try { + long startTime = System.nanoTime(); + thread.join(timeoutMillis); + assertTrue(thread.isAlive()); + assertTrue(millisElapsedSince(startTime) >= timeoutMillis); + } catch (InterruptedException ie) { + fail("Unexpected InterruptedException"); + } + } /** * Fails with message "should throw exception".