493 |
|
*/ |
494 |
|
public void testInterruptedTimedPoll() throws InterruptedException { |
495 |
|
final BlockingQueue<Integer> q = populatedQueue(SIZE); |
496 |
< |
final CountDownLatch aboutToWait = new CountDownLatch(1); |
496 |
> |
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
497 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
498 |
|
public void realRun() throws InterruptedException { |
499 |
|
long startTime = System.nanoTime(); |
500 |
|
for (int i = 0; i < SIZE; ++i) { |
501 |
|
assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); |
502 |
|
} |
503 |
< |
aboutToWait.countDown(); |
503 |
> |
|
504 |
> |
pleaseInterrupt.countDown(); |
505 |
|
try { |
506 |
|
q.poll(LONG_DELAY_MS, MILLISECONDS); |
507 |
|
shouldThrow(); |
508 |
< |
} catch (InterruptedException success) { |
509 |
< |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
510 |
< |
} |
508 |
> |
} catch (InterruptedException success) {} |
509 |
> |
assertFalse(Thread.interrupted()); |
510 |
> |
|
511 |
> |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
512 |
|
}}); |
513 |
|
|
514 |
< |
await(aboutToWait); |
514 |
> |
await(pleaseInterrupt); |
515 |
|
assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
516 |
|
t.interrupt(); |
517 |
|
awaitTermination(t); |