756 |
|
*/ |
757 |
|
public void testInterruptedTimedPoll() throws InterruptedException { |
758 |
|
final BlockingQueue<Integer> q = populatedDeque(SIZE); |
759 |
< |
final CountDownLatch aboutToWait = new CountDownLatch(1); |
759 |
> |
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
760 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
761 |
|
public void realRun() throws InterruptedException { |
762 |
|
long startTime = System.nanoTime(); |
763 |
|
for (int i = 0; i < SIZE; ++i) { |
764 |
|
assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); |
765 |
|
} |
766 |
< |
aboutToWait.countDown(); |
766 |
> |
|
767 |
> |
pleaseInterrupt.countDown(); |
768 |
|
try { |
769 |
|
q.poll(LONG_DELAY_MS, MILLISECONDS); |
770 |
|
shouldThrow(); |
771 |
< |
} catch (InterruptedException success) { |
772 |
< |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
773 |
< |
} |
771 |
> |
} catch (InterruptedException success) {} |
772 |
> |
assertFalse(Thread.interrupted()); |
773 |
> |
|
774 |
> |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
775 |
|
}}); |
776 |
|
|
777 |
< |
await(aboutToWait); |
777 |
> |
await(pleaseInterrupt); |
778 |
|
assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
779 |
|
t.interrupt(); |
780 |
|
awaitTermination(t); |
1078 |
|
shouldThrow(); |
1079 |
|
} catch (InterruptedException success) {} |
1080 |
|
assertFalse(Thread.interrupted()); |
1081 |
+ |
|
1082 |
|
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
1083 |
|
}}); |
1084 |
|
|
1124 |
|
assertTrue(q.offerFirst(zero, LONG_DELAY_MS, MILLISECONDS)); |
1125 |
|
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
1126 |
|
barrier.await(); |
1127 |
< |
assertThreadStaysAlive(t); |
1127 |
> |
assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
1128 |
|
t.interrupt(); |
1129 |
|
awaitTermination(t); |
1130 |
|
} |