663 |
|
q.offer(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS); |
664 |
|
shouldThrow(); |
665 |
|
} catch (InterruptedException success) {} |
666 |
+ |
assertFalse(Thread.interrupted()); |
667 |
|
}}); |
668 |
|
|
669 |
|
await(pleaseInterrupt); |
757 |
|
*/ |
758 |
|
public void testInterruptedTimedPoll() throws InterruptedException { |
759 |
|
final BlockingQueue<Integer> q = populatedDeque(SIZE); |
760 |
< |
final CountDownLatch aboutToWait = new CountDownLatch(1); |
760 |
> |
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
761 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
762 |
|
public void realRun() throws InterruptedException { |
763 |
|
long startTime = System.nanoTime(); |
764 |
|
for (int i = 0; i < SIZE; ++i) { |
765 |
|
assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); |
766 |
|
} |
767 |
< |
aboutToWait.countDown(); |
767 |
> |
|
768 |
> |
pleaseInterrupt.countDown(); |
769 |
|
try { |
770 |
|
q.poll(LONG_DELAY_MS, MILLISECONDS); |
771 |
|
shouldThrow(); |
772 |
< |
} catch (InterruptedException success) { |
773 |
< |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
774 |
< |
} |
772 |
> |
} catch (InterruptedException success) {} |
773 |
> |
assertFalse(Thread.interrupted()); |
774 |
> |
|
775 |
> |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
776 |
|
}}); |
777 |
|
|
778 |
< |
await(aboutToWait); |
779 |
< |
waitForThreadToEnterWaitState(t); |
778 |
> |
await(pleaseInterrupt); |
779 |
> |
assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
780 |
|
t.interrupt(); |
781 |
|
awaitTermination(t); |
782 |
|
checkEmpty(q); |
894 |
|
q.offerFirst(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS); |
895 |
|
shouldThrow(); |
896 |
|
} catch (InterruptedException success) {} |
897 |
+ |
assertFalse(Thread.interrupted()); |
898 |
|
}}); |
899 |
|
|
900 |
|
await(pleaseInterrupt); |
1080 |
|
shouldThrow(); |
1081 |
|
} catch (InterruptedException success) {} |
1082 |
|
assertFalse(Thread.interrupted()); |
1083 |
+ |
|
1084 |
|
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
1085 |
|
}}); |
1086 |
|
|
1087 |
|
await(pleaseInterrupt); |
1088 |
< |
assertThreadStaysAlive(t); |
1088 |
> |
assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
1089 |
|
t.interrupt(); |
1090 |
|
awaitTermination(t); |
1091 |
|
} |
1118 |
|
q.pollFirst(LONG_DELAY_MS, MILLISECONDS); |
1119 |
|
shouldThrow(); |
1120 |
|
} catch (InterruptedException success) {} |
1121 |
+ |
assertFalse(Thread.interrupted()); |
1122 |
|
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
1123 |
|
}}); |
1124 |
|
|
1127 |
|
assertTrue(q.offerFirst(zero, LONG_DELAY_MS, MILLISECONDS)); |
1128 |
|
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
1129 |
|
barrier.await(); |
1130 |
< |
assertThreadStaysAlive(t); |
1130 |
> |
assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
1131 |
|
t.interrupt(); |
1132 |
|
awaitTermination(t); |
1133 |
|
} |
1354 |
|
}}); |
1355 |
|
|
1356 |
|
await(pleaseInterrupt); |
1357 |
< |
assertThreadStaysAlive(t); |
1357 |
> |
assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
1358 |
|
t.interrupt(); |
1359 |
|
awaitTermination(t); |
1360 |
|
checkEmpty(q); |