440 |
|
final CountDownLatch aboutToWait = new CountDownLatch(1); |
441 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
442 |
|
public void realRun() throws InterruptedException { |
443 |
+ |
long startTime = System.nanoTime(); |
444 |
|
for (int i = 0; i < SIZE; ++i) { |
444 |
– |
long t0 = System.nanoTime(); |
445 |
|
assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS)); |
446 |
– |
assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS); |
446 |
|
} |
448 |
– |
long t0 = System.nanoTime(); |
447 |
|
aboutToWait.countDown(); |
448 |
|
try { |
449 |
< |
q.poll(MEDIUM_DELAY_MS, MILLISECONDS); |
449 |
> |
q.poll(LONG_DELAY_MS, MILLISECONDS); |
450 |
|
shouldThrow(); |
451 |
|
} catch (InterruptedException success) { |
452 |
< |
assertTrue(millisElapsedSince(t0) < MEDIUM_DELAY_MS); |
452 |
> |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
453 |
|
} |
454 |
|
}}); |
455 |
|
|
456 |
< |
aboutToWait.await(); |
457 |
< |
waitForThreadToEnterWaitState(t, SMALL_DELAY_MS); |
456 |
> |
await(aboutToWait); |
457 |
> |
waitForThreadToEnterWaitState(t, LONG_DELAY_MS); |
458 |
|
t.interrupt(); |
459 |
< |
awaitTermination(t, MEDIUM_DELAY_MS); |
459 |
> |
awaitTermination(t); |
460 |
|
checkEmpty(q); |
461 |
|
} |
462 |
|
|