412 |
|
*/ |
413 |
|
public void testInterruptedTimedPoll() throws InterruptedException { |
414 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
415 |
+ |
final DelayQueue q = populatedQueue(SIZE); |
416 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
417 |
|
public void realRun() throws InterruptedException { |
418 |
< |
DelayQueue q = populatedQueue(SIZE); |
418 |
> |
long startTime = System.nanoTime(); |
419 |
|
for (int i = 0; i < SIZE; ++i) { |
420 |
< |
assertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, MILLISECONDS))); |
420 |
> |
assertEquals(new PDelay(i), |
421 |
> |
((PDelay)q.poll(LONG_DELAY_MS, MILLISECONDS))); |
422 |
|
} |
423 |
|
|
424 |
|
Thread.currentThread().interrupt(); |
434 |
|
shouldThrow(); |
435 |
|
} catch (InterruptedException success) {} |
436 |
|
assertFalse(Thread.interrupted()); |
437 |
+ |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
438 |
|
}}); |
439 |
|
|
440 |
|
await(pleaseInterrupt); |
441 |
|
assertThreadStaysAlive(t); |
442 |
|
t.interrupt(); |
443 |
|
awaitTermination(t); |
444 |
+ |
checkEmpty(q); |
445 |
|
} |
446 |
|
|
447 |
|
/** |