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.63 by jsr166, Mon Oct 11 08:30:01 2010 UTC vs.
Revision 1.66 by jsr166, Thu Oct 28 17:57:26 2010 UTC

# Line 11 | Line 11 | import java.util.PropertyPermission;
11   import java.util.concurrent.*;
12   import java.util.concurrent.atomic.AtomicReference;
13   import static java.util.concurrent.TimeUnit.MILLISECONDS;
14 + import static java.util.concurrent.TimeUnit.NANOSECONDS;
15   import java.security.CodeSource;
16   import java.security.Permission;
17   import java.security.PermissionCollection;
# Line 605 | Line 606 | public class JSR166TestCase extends Test
606      }
607  
608      /**
609 +     * Waits up to the specified number of milliseconds for the given
610 +     * thread to enter a wait state: BLOCKED, WAITING, or TIMED_WAITING.
611 +     */
612 +    void waitForThreadToEnterWaitState(Thread thread, long timeoutMillis) {
613 +        long timeoutNanos = timeoutMillis * 1000L * 1000L;
614 +        long t0 = System.nanoTime();
615 +        for (;;) {
616 +            Thread.State s = thread.getState();
617 +            if (s == Thread.State.BLOCKED ||
618 +                s == Thread.State.WAITING ||
619 +                s == Thread.State.TIMED_WAITING ||
620 +                System.nanoTime() - t0 > timeoutNanos)
621 +                return;
622 +            Thread.yield();
623 +        }
624 +    }
625 +
626 +    /**
627 +     * Returns the number of milliseconds since time given by
628 +     * startNanoTime, which must have been previously returned from a
629 +     * call to {@link System.nanoTime()}.
630 +     */
631 +    long millisElapsedSince(long startNanoTime) {
632 +        return NANOSECONDS.toMillis(System.nanoTime() - startNanoTime);
633 +    }
634 +    
635 +    /**
636       * Returns a new started daemon Thread running the given runnable.
637       */
638      Thread newStartedThread(Runnable runnable) {
# Line 746 | Line 774 | public class JSR166TestCase extends Test
774  
775      public Callable<String> latchAwaitingStringTask(final CountDownLatch latch) {
776          return new CheckedCallable<String>() {
777 <            public String realCall() {
777 >            protected String realCall() {
778                  try {
779                      latch.await();
780                  } catch (InterruptedException quittingTime) {}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines