211 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
212 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
213 |
|
public void realRun() throws InterruptedException { |
214 |
< |
long t0 = System.nanoTime(); |
215 |
< |
assertFalse(q.offer(new Object(), SHORT_DELAY_MS, MILLISECONDS)); |
216 |
< |
assertTrue(millisElapsedSince(t0) >= SHORT_DELAY_MS); |
214 |
> |
long startTime = System.nanoTime(); |
215 |
> |
assertFalse(q.offer(new Object(), timeoutMillis(), MILLISECONDS)); |
216 |
> |
assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); |
217 |
|
pleaseInterrupt.countDown(); |
218 |
– |
t0 = System.nanoTime(); |
218 |
|
try { |
219 |
< |
q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS); |
219 |
> |
q.offer(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS); |
220 |
|
shouldThrow(); |
221 |
|
} catch (InterruptedException success) {} |
223 |
– |
assertTrue(millisElapsedSince(t0) < MEDIUM_DELAY_MS); |
222 |
|
}}); |
223 |
|
|
224 |
< |
assertTrue(pleaseInterrupt.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
224 |
> |
await(pleaseInterrupt); |
225 |
|
t.interrupt(); |
226 |
< |
awaitTermination(t, MEDIUM_DELAY_MS); |
226 |
> |
awaitTermination(t); |
227 |
|
} |
228 |
|
|
229 |
|
/** |