equal
deleted
inserted
replaced
42 import java.util.HashSet; |
42 import java.util.HashSet; |
43 import java.util.concurrent.ThreadLocalRandom; |
43 import java.util.concurrent.ThreadLocalRandom; |
44 import java.util.concurrent.locks.AbstractQueuedSynchronizer; |
44 import java.util.concurrent.locks.AbstractQueuedSynchronizer; |
45 import java.util.concurrent.locks.AbstractQueuedSynchronizer.ConditionObject; |
45 import java.util.concurrent.locks.AbstractQueuedSynchronizer.ConditionObject; |
46 |
46 |
47 import junit.framework.AssertionFailedError; |
|
48 import junit.framework.Test; |
47 import junit.framework.Test; |
49 import junit.framework.TestSuite; |
48 import junit.framework.TestSuite; |
50 |
49 |
51 @SuppressWarnings("WaitNotInLoop") // we implement spurious-wakeup freedom |
50 @SuppressWarnings("WaitNotInLoop") // we implement spurious-wakeup freedom |
52 public class AbstractQueuedSynchronizerTest extends JSR166TestCase { |
51 public class AbstractQueuedSynchronizerTest extends JSR166TestCase { |
170 */ |
169 */ |
171 void waitForQueuedThread(AbstractQueuedSynchronizer sync, Thread t) { |
170 void waitForQueuedThread(AbstractQueuedSynchronizer sync, Thread t) { |
172 long startTime = System.nanoTime(); |
171 long startTime = System.nanoTime(); |
173 while (!sync.isQueued(t)) { |
172 while (!sync.isQueued(t)) { |
174 if (millisElapsedSince(startTime) > LONG_DELAY_MS) |
173 if (millisElapsedSince(startTime) > LONG_DELAY_MS) |
175 throw new AssertionFailedError("timed out"); |
174 throw new AssertionError("timed out"); |
176 Thread.yield(); |
175 Thread.yield(); |
177 } |
176 } |
178 assertTrue(t.isAlive()); |
177 assertTrue(t.isAlive()); |
179 } |
178 } |
180 |
179 |