--- jsr166/src/test/tck/JSR166TestCase.java 2010/10/11 03:54:10 1.61 +++ jsr166/src/test/tck/JSR166TestCase.java 2010/10/21 23:22:49 1.65 @@ -96,6 +96,9 @@ public class JSR166TestCase extends Test private static final boolean useSecurityManager = Boolean.getBoolean("jsr166.useSecurityManager"); + protected static final boolean expensiveTests = + Boolean.getBoolean("jsr166.expensiveTests"); + /** * If true, report on stdout all "slow" tests, that is, ones that * take more than profileThreshold milliseconds to execute. @@ -128,7 +131,7 @@ public class JSR166TestCase extends Test System.out.printf("%n%s: %d%n", toString(), elapsedMillis); } } - + /** * Runs all JSR166 unit tests using junit.textui.TestRunner */ @@ -602,6 +605,24 @@ public class JSR166TestCase extends Test } /** + * Waits up to the specified number of milliseconds for the given + * thread to enter a wait state: BLOCKED, WAITING, or TIMED_WAITING. + */ + void waitForThreadToEnterWaitState(Thread thread, long timeoutMillis) { + long timeoutNanos = timeoutMillis * 1000L * 1000L; + long t0 = System.nanoTime(); + for (;;) { + Thread.State s = thread.getState(); + if (s == Thread.State.BLOCKED || + s == Thread.State.WAITING || + s == Thread.State.TIMED_WAITING || + System.nanoTime() - t0 > timeoutNanos) + return; + Thread.yield(); + } + } + + /** * Returns a new started daemon Thread running the given runnable. */ Thread newStartedThread(Runnable runnable) { @@ -743,7 +764,7 @@ public class JSR166TestCase extends Test public Callable latchAwaitingStringTask(final CountDownLatch latch) { return new CheckedCallable() { - public String realCall() { + protected String realCall() { try { latch.await(); } catch (InterruptedException quittingTime) {} @@ -804,6 +825,15 @@ public class JSR166TestCase extends Test } } + public Runnable possiblyInterruptedRunnable(final long timeoutMillis) { + return new CheckedRunnable() { + protected void realRun() { + try { + Thread.sleep(timeoutMillis); + } catch (InterruptedException ok) {} + }}; + } + public class MediumPossiblyInterruptedRunnable extends CheckedRunnable { protected void realRun() { try {