--- jsr166/src/test/tck/JSR166TestCase.java 2010/10/28 17:57:26 1.66 +++ jsr166/src/test/tck/JSR166TestCase.java 2010/11/22 06:53:32 1.71 @@ -260,7 +260,7 @@ public class JSR166TestCase extends Test SHORT_DELAY_MS = getShortDelay(); SMALL_DELAY_MS = SHORT_DELAY_MS * 5; MEDIUM_DELAY_MS = SHORT_DELAY_MS * 10; - LONG_DELAY_MS = SHORT_DELAY_MS * 50; + LONG_DELAY_MS = SHORT_DELAY_MS * 200; } /** @@ -289,7 +289,7 @@ public class JSR166TestCase extends Test * earlier by threadRecordFailure. */ public void tearDown() throws Exception { - Throwable t = threadFailure.get(); + Throwable t = threadFailure.getAndSet(null); if (t != null) { if (t instanceof Error) throw (Error) t; @@ -447,7 +447,7 @@ public class JSR166TestCase extends Test try { exec.shutdown(); assertTrue("ExecutorService did not terminate in a timely manner", - exec.awaitTermination(LONG_DELAY_MS, MILLISECONDS)); + exec.awaitTermination(2 * LONG_DELAY_MS, MILLISECONDS)); } catch (SecurityException ok) { // Allowed in case test doesn't have privs } catch (InterruptedException ie) { @@ -616,9 +616,14 @@ public class JSR166TestCase extends Test Thread.State s = thread.getState(); if (s == Thread.State.BLOCKED || s == Thread.State.WAITING || - s == Thread.State.TIMED_WAITING || - System.nanoTime() - t0 > timeoutNanos) + s == Thread.State.TIMED_WAITING) return; + else if (s == Thread.State.TERMINATED) + fail("Unexpected thread termination"); + else if (System.nanoTime() - t0 > timeoutNanos) { + threadAssertTrue(thread.isAlive()); + return; + } Thread.yield(); } } @@ -631,7 +636,7 @@ public class JSR166TestCase extends Test long millisElapsedSince(long startNanoTime) { return NANOSECONDS.toMillis(System.nanoTime() - startNanoTime); } - + /** * Returns a new started daemon Thread running the given runnable. */