test/jdk/java/util/concurrent/tck/AbstractQueuedLongSynchronizerTest.java
changeset 48843 21efc1774302
parent 48046 98801bd22f5b
child 50764 5637aca18f1d
equal deleted inserted replaced
48842:a5a2e4770524 48843:21efc1774302
    41 import java.util.HashSet;
    41 import java.util.HashSet;
    42 import java.util.concurrent.ThreadLocalRandom;
    42 import java.util.concurrent.ThreadLocalRandom;
    43 import java.util.concurrent.locks.AbstractQueuedLongSynchronizer;
    43 import java.util.concurrent.locks.AbstractQueuedLongSynchronizer;
    44 import java.util.concurrent.locks.AbstractQueuedLongSynchronizer.ConditionObject;
    44 import java.util.concurrent.locks.AbstractQueuedLongSynchronizer.ConditionObject;
    45 
    45 
    46 import junit.framework.AssertionFailedError;
       
    47 import junit.framework.Test;
    46 import junit.framework.Test;
    48 import junit.framework.TestSuite;
    47 import junit.framework.TestSuite;
    49 
    48 
    50 @SuppressWarnings("WaitNotInLoop") // we implement spurious-wakeup freedom
    49 @SuppressWarnings("WaitNotInLoop") // we implement spurious-wakeup freedom
    51 public class AbstractQueuedLongSynchronizerTest extends JSR166TestCase {
    50 public class AbstractQueuedLongSynchronizerTest extends JSR166TestCase {
   166     void waitForQueuedThread(AbstractQueuedLongSynchronizer sync,
   165     void waitForQueuedThread(AbstractQueuedLongSynchronizer sync,
   167                              Thread t) {
   166                              Thread t) {
   168         long startTime = System.nanoTime();
   167         long startTime = System.nanoTime();
   169         while (!sync.isQueued(t)) {
   168         while (!sync.isQueued(t)) {
   170             if (millisElapsedSince(startTime) > LONG_DELAY_MS)
   169             if (millisElapsedSince(startTime) > LONG_DELAY_MS)
   171                 throw new AssertionFailedError("timed out");
   170                 throw new AssertionError("timed out");
   172             Thread.yield();
   171             Thread.yield();
   173         }
   172         }
   174         assertTrue(t.isAlive());
   173         assertTrue(t.isAlive());
   175     }
   174     }
   176 
   175