319 |
|
} |
320 |
|
|
321 |
|
/** |
322 |
< |
* timed offer does not time out |
322 |
> |
* Queue is unbounded, so timed offer never times out |
323 |
|
*/ |
324 |
|
public void testTimedOffer() { |
325 |
|
final PriorityBlockingQueue q = new PriorityBlockingQueue(2); |
422 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
423 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
424 |
|
public void realRun() throws InterruptedException { |
425 |
– |
long startTime = System.nanoTime(); |
425 |
|
for (int i = 0; i < SIZE; i++) |
426 |
|
assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); |
427 |
|
|
434 |
|
|
435 |
|
pleaseInterrupt.countDown(); |
436 |
|
try { |
437 |
< |
q.poll(LONG_DELAY_MS, MILLISECONDS); |
437 |
> |
q.poll(LONGER_DELAY_MS, MILLISECONDS); |
438 |
|
shouldThrow(); |
439 |
|
} catch (InterruptedException success) {} |
440 |
|
assertFalse(Thread.interrupted()); |
442 |
– |
|
443 |
– |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
441 |
|
}}); |
442 |
|
|
443 |
|
await(pleaseInterrupt); |