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.76 by dl, Fri May 6 11:22:07 2011 UTC vs.
Revision 1.78 by jsr166, Sat May 7 19:03:26 2011 UTC

# Line 449 | Line 449 | public class JSR166TestCase extends Test
449       */
450      public static void delay(long ms) throws InterruptedException {
451          long startTime = System.nanoTime();
452 <        long ns = ms * 1000 * 1000;
452 >        long ns = ms * 1000 * 1000;
453          for (;;) {
454              if (ms > 0L)
455                  Thread.sleep(ms);
# Line 457 | Line 457 | public class JSR166TestCase extends Test
457                  Thread.yield();
458              long d = ns - (System.nanoTime() - startTime);
459              if (d > 0L)
460 <                ms = d / (1000 * 1000);
460 >                ms = d / (1000 * 1000);
461              else
462                  break;
463          }
# Line 478 | Line 478 | public class JSR166TestCase extends Test
478          }
479      }
480  
481 +    /**
482 +     * Checks that thread does not terminate within timeoutMillis
483 +     * milliseconds (that is, Thread.join times out).
484 +     */
485 +    public void assertThreadJoinTimesOut(Thread thread, long timeoutMillis) {
486 +        try {
487 +            long startTime = System.nanoTime();
488 +            thread.join(timeoutMillis);
489 +            assertTrue(thread.isAlive());
490 +            assertTrue(millisElapsedSince(startTime) >= timeoutMillis);
491 +        } catch (InterruptedException ie) {
492 +            fail("Unexpected InterruptedException");
493 +        }
494 +    }
495  
496      /**
497       * Fails with message "should throw exception".

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines