--- jsr166/src/test/tck/JSR166TestCase.java 2009/08/04 00:23:18 1.37 +++ jsr166/src/test/tck/JSR166TestCase.java 2009/11/17 21:51:45 1.39 @@ -395,6 +395,25 @@ public class JSR166TestCase extends Test public void refresh() {} } + /** + * Sleep until the timeout has elapsed, or interrupted. + * Does NOT throw InterruptedException. + */ + void sleepTillInterrupted(long timeoutMillis) { + try { + Thread.sleep(timeoutMillis); + } catch (InterruptedException wakeup) { + } + } + + /** + * Returns a new started Thread running the given runnable. + */ + Thread newStartedThread(Runnable runnable) { + Thread t = new Thread(runnable); + t.start(); + return t; + } // Some convenient Runnable classes @@ -547,7 +566,7 @@ public class JSR166TestCase extends Test try { Thread.sleep(SMALL_DELAY_MS); done = true; - } catch (Exception e) { + } catch (InterruptedException ok) { } } } @@ -558,7 +577,7 @@ public class JSR166TestCase extends Test try { Thread.sleep(MEDIUM_DELAY_MS); done = true; - } catch (Exception e) { + } catch (InterruptedException ok) { } } } @@ -569,7 +588,7 @@ public class JSR166TestCase extends Test try { Thread.sleep(LONG_DELAY_MS); done = true; - } catch (Exception e) { + } catch (InterruptedException ok) { } } } @@ -587,7 +606,7 @@ public class JSR166TestCase extends Test try { Thread.sleep(SMALL_DELAY_MS); done = true; - } catch (Exception e) { + } catch (InterruptedException ok) { } return Boolean.TRUE; }