226 |
|
|
227 |
|
Thread.currentThread().interrupt(); |
228 |
|
try { |
229 |
< |
q.poll(LONG_DELAY_MS, MILLISECONDS); |
229 |
> |
q.poll(randomTimeout(), randomTimeUnit()); |
230 |
|
shouldThrow(); |
231 |
|
} catch (InterruptedException success) {} |
232 |
|
assertFalse(Thread.interrupted()); |
247 |
|
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
248 |
|
|
249 |
|
barrier.await(); |
250 |
< |
assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
250 |
> |
if (randomBoolean()) assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
251 |
|
t.interrupt(); |
252 |
|
awaitTermination(t); |
253 |
|
} |
269 |
|
}}); |
270 |
|
|
271 |
|
await(threadStarted); |
272 |
< |
assertThreadBlocks(t, Thread.State.WAITING); |
272 |
> |
if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); |
273 |
|
t.interrupt(); |
274 |
|
awaitTermination(t); |
275 |
|
} |
298 |
|
*/ |
299 |
|
public void testTimedPollFromEmptyBlocksInterruptibly() { |
300 |
|
final BlockingQueue q = emptyCollection(); |
301 |
< |
final CountDownLatch threadStarted = new CountDownLatch(1); |
301 |
> |
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
302 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
303 |
|
public void realRun() { |
304 |
< |
threadStarted.countDown(); |
304 |
> |
pleaseInterrupt.countDown(); |
305 |
|
try { |
306 |
< |
q.poll(2 * LONG_DELAY_MS, MILLISECONDS); |
306 |
> |
q.poll(LONGER_DELAY_MS, MILLISECONDS); |
307 |
|
shouldThrow(); |
308 |
|
} catch (InterruptedException success) {} |
309 |
|
assertFalse(Thread.interrupted()); |
310 |
|
}}); |
311 |
|
|
312 |
< |
await(threadStarted); |
313 |
< |
assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
312 |
> |
await(pleaseInterrupt); |
313 |
> |
if (randomBoolean()) assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
314 |
|
t.interrupt(); |
315 |
|
awaitTermination(t); |
316 |
|
} |
325 |
|
public void realRun() { |
326 |
|
Thread.currentThread().interrupt(); |
327 |
|
try { |
328 |
< |
q.poll(2 * LONG_DELAY_MS, MILLISECONDS); |
328 |
> |
q.poll(LONGER_DELAY_MS, MILLISECONDS); |
329 |
|
shouldThrow(); |
330 |
|
} catch (InterruptedException success) {} |
331 |
|
assertFalse(Thread.interrupted()); |