278 |
|
*/ |
279 |
|
public void testInterruptedTimedPoll() throws InterruptedException { |
280 |
|
final BlockingQueue<Integer> q = populatedQueue(SIZE); |
281 |
< |
final CountDownLatch aboutToWait = new CountDownLatch(1); |
281 |
> |
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
282 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
283 |
|
public void realRun() throws InterruptedException { |
284 |
|
long startTime = System.nanoTime(); |
285 |
|
for (int i = 0; i < SIZE; ++i) |
286 |
|
assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); |
287 |
< |
aboutToWait.countDown(); |
287 |
> |
|
288 |
> |
pleaseInterrupt.countDown(); |
289 |
|
try { |
290 |
|
q.poll(LONG_DELAY_MS, MILLISECONDS); |
291 |
|
shouldThrow(); |
292 |
|
} catch (InterruptedException success) {} |
293 |
+ |
assertFalse(Thread.interrupted()); |
294 |
+ |
|
295 |
|
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
296 |
|
}}); |
297 |
|
|
298 |
< |
await(aboutToWait); |
298 |
> |
await(pleaseInterrupt); |
299 |
|
assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
300 |
|
t.interrupt(); |
301 |
|
awaitTermination(t); |
318 |
|
q.poll(LONG_DELAY_MS, MILLISECONDS); |
319 |
|
shouldThrow(); |
320 |
|
} catch (InterruptedException success) {} |
321 |
+ |
assertFalse(Thread.interrupted()); |
322 |
|
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
323 |
|
}}); |
324 |
|
|