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.79 by jsr166, Mon May 9 20:00:19 2011 UTC vs.
Revision 1.80 by jsr166, Fri May 13 21:48:58 2011 UTC

# Line 451 | Line 451 | public class JSR166TestCase extends Test
451       * if the sleep is shorter than specified, may re-sleep or yield
452       * until time elapses.
453       */
454 <    public static void delay(long ms) throws InterruptedException {
454 >    public static void delay(long millis) throws InterruptedException {
455          long startTime = System.nanoTime();
456 <        long ns = ms * 1000 * 1000;
456 >        long ns = millis * 1000 * 1000;
457          for (;;) {
458 <            if (ms > 0L)
459 <                Thread.sleep(ms);
458 >            if (millis > 0L)
459 >                Thread.sleep(millis);
460              else // too short to sleep
461                  Thread.yield();
462              long d = ns - (System.nanoTime() - startTime);
463              if (d > 0L)
464 <                ms = d / (1000 * 1000);
464 >                millis = d / (1000 * 1000);
465              else
466                  break;
467          }
# Line 483 | Line 483 | public class JSR166TestCase extends Test
483      }
484  
485      /**
486 <     * Checks that thread does not terminate within timeoutMillis
487 <     * milliseconds (that is, Thread.join times out).
486 >     * Checks that thread does not terminate within the given millisecond delay.
487       */
488 <    public void assertThreadJoinTimesOut(Thread thread, long timeoutMillis) {
488 >    public void assertThreadStaysAlive(Thread thread, long millis) {
489          try {
490 <            long startTime = System.nanoTime();
491 <            thread.join(timeoutMillis);
490 >            // No need to optimize the failing case via Thread.join.
491 >            delay(millis);
492              assertTrue(thread.isAlive());
494            assertTrue(millisElapsedSince(startTime) >= timeoutMillis);
493          } catch (InterruptedException ie) {
494              fail("Unexpected InterruptedException");
495          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines