291 |
|
}}); |
292 |
|
|
293 |
|
await(pleaseInterrupt); |
294 |
< |
assertThreadBlocks(t, Thread.State.WAITING); |
294 |
> |
if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); |
295 |
|
t.interrupt(); |
296 |
|
awaitTermination(t); |
297 |
|
assertEquals(SIZE, q.size()); |
333 |
|
assertEquals(0, q.take()); |
334 |
|
|
335 |
|
await(pleaseInterrupt); |
336 |
< |
assertThreadBlocks(t, Thread.State.WAITING); |
336 |
> |
if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); |
337 |
|
t.interrupt(); |
338 |
|
awaitTermination(t); |
339 |
|
assertEquals(0, q.remainingCapacity()); |
349 |
|
public void realRun() throws InterruptedException { |
350 |
|
q.put(new Object()); |
351 |
|
q.put(new Object()); |
352 |
– |
|
352 |
|
long startTime = System.nanoTime(); |
353 |
+ |
|
354 |
|
assertFalse(q.offer(new Object(), timeoutMillis(), MILLISECONDS)); |
355 |
|
assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); |
356 |
|
|
357 |
|
Thread.currentThread().interrupt(); |
358 |
|
try { |
359 |
< |
q.offer(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS); |
359 |
> |
q.offer(new Object(), randomTimeout(), randomTimeUnit()); |
360 |
|
shouldThrow(); |
361 |
|
} catch (InterruptedException success) {} |
362 |
|
assertFalse(Thread.interrupted()); |
363 |
|
|
364 |
|
pleaseInterrupt.countDown(); |
365 |
|
try { |
366 |
< |
q.offer(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS); |
366 |
> |
q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS); |
367 |
|
shouldThrow(); |
368 |
|
} catch (InterruptedException success) {} |
369 |
|
assertFalse(Thread.interrupted()); |
370 |
+ |
|
371 |
+ |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
372 |
|
}}); |
373 |
|
|
374 |
|
await(pleaseInterrupt); |
375 |
< |
assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
375 |
> |
if (randomBoolean()) assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
376 |
|
t.interrupt(); |
377 |
|
awaitTermination(t); |
378 |
|
} |
413 |
|
}}); |
414 |
|
|
415 |
|
await(pleaseInterrupt); |
416 |
< |
assertThreadBlocks(t, Thread.State.WAITING); |
416 |
> |
if (randomBoolean()) assertThreadBlocks(t, Thread.State.WAITING); |
417 |
|
t.interrupt(); |
418 |
|
awaitTermination(t); |
419 |
|
} |
471 |
|
|
472 |
|
Thread.currentThread().interrupt(); |
473 |
|
try { |
474 |
< |
q.poll(LONG_DELAY_MS, MILLISECONDS); |
474 |
> |
q.poll(randomTimeout(), randomTimeUnit()); |
475 |
|
shouldThrow(); |
476 |
|
} catch (InterruptedException success) {} |
477 |
|
assertFalse(Thread.interrupted()); |
487 |
|
}}); |
488 |
|
|
489 |
|
await(pleaseInterrupt); |
490 |
< |
assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
490 |
> |
if (randomBoolean()) assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
491 |
|
t.interrupt(); |
492 |
|
awaitTermination(t); |
493 |
|
checkEmpty(q); |