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.64 by jsr166, Fri Oct 15 22:30:07 2010 UTC vs.
Revision 1.65 by jsr166, Thu Oct 21 23:22:49 2010 UTC

# Line 605 | Line 605 | public class JSR166TestCase extends Test
605      }
606  
607      /**
608 +     * Waits up to the specified number of milliseconds for the given
609 +     * thread to enter a wait state: BLOCKED, WAITING, or TIMED_WAITING.
610 +     */
611 +    void waitForThreadToEnterWaitState(Thread thread, long timeoutMillis) {
612 +        long timeoutNanos = timeoutMillis * 1000L * 1000L;
613 +        long t0 = System.nanoTime();
614 +        for (;;) {
615 +            Thread.State s = thread.getState();
616 +            if (s == Thread.State.BLOCKED ||
617 +                s == Thread.State.WAITING ||
618 +                s == Thread.State.TIMED_WAITING ||
619 +                System.nanoTime() - t0 > timeoutNanos)
620 +                return;
621 +            Thread.yield();
622 +        }
623 +    }
624 +
625 +    /**
626       * Returns a new started daemon Thread running the given runnable.
627       */
628      Thread newStartedThread(Runnable runnable) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines