ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/JSR166TestCase.java
(Generate patch)

Comparing jsr166/src/test/tck/JSR166TestCase.java (file contents):
Revision 1.58 by jsr166, Wed Oct 6 02:11:57 2010 UTC vs.
Revision 1.59 by jsr166, Wed Oct 6 02:58:04 2010 UTC

# Line 534 | Line 534 | public class JSR166TestCase extends Test
534      }
535  
536      /**
537 <     * Sleep until the timeout has elapsed, or interrupted.
537 >     * Sleeps until the timeout has elapsed, or interrupted.
538       * Does <em>NOT</em> throw InterruptedException.
539       */
540      void sleepTillInterrupted(long timeoutMillis) {
# Line 553 | Line 553 | public class JSR166TestCase extends Test
553          return t;
554      }
555  
556 +    /**
557 +     * Waits for the specified time (in milliseconds) for the thread
558 +     * to terminate (using {@link Thread#join(long)}), else interrupts
559 +     * the thread (in the hope that it may terminate later) and fails.
560 +     */
561 +    void awaitTermination(Thread t, long timeoutMillis) {
562 +        try {
563 +            t.join(timeoutMillis);
564 +        } catch (InterruptedException ie) {
565 +            threadUnexpectedException(ie);
566 +        } finally {
567 +            if (t.isAlive()) {
568 +                t.interrupt();
569 +                fail("Test timed out");
570 +            }
571 +        }
572 +    }
573 +
574      // Some convenient Runnable classes
575  
576      public abstract class CheckedRunnable implements Runnable {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines