351 |
|
q.offer(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS); |
352 |
|
shouldThrow(); |
353 |
|
} catch (InterruptedException success) {} |
354 |
+ |
assertFalse(Thread.interrupted()); |
355 |
|
}}); |
356 |
|
|
357 |
|
await(pleaseInterrupt); |
445 |
|
*/ |
446 |
|
public void testInterruptedTimedPoll() throws InterruptedException { |
447 |
|
final BlockingQueue<Integer> q = populatedQueue(SIZE); |
448 |
< |
final CountDownLatch aboutToWait = new CountDownLatch(1); |
448 |
> |
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
449 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
450 |
|
public void realRun() throws InterruptedException { |
451 |
|
long startTime = System.nanoTime(); |
452 |
|
for (int i = 0; i < SIZE; ++i) { |
453 |
|
assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); |
454 |
|
} |
455 |
< |
aboutToWait.countDown(); |
455 |
> |
|
456 |
> |
pleaseInterrupt.countDown(); |
457 |
|
try { |
458 |
|
q.poll(LONG_DELAY_MS, MILLISECONDS); |
459 |
|
shouldThrow(); |
460 |
< |
} catch (InterruptedException success) { |
461 |
< |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
462 |
< |
} |
460 |
> |
} catch (InterruptedException success) {} |
461 |
> |
assertFalse(Thread.interrupted()); |
462 |
> |
|
463 |
> |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
464 |
|
}}); |
465 |
|
|
466 |
< |
await(aboutToWait); |
466 |
> |
await(pleaseInterrupt); |
467 |
|
assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
468 |
|
t.interrupt(); |
469 |
|
awaitTermination(t); |