341 |
|
*/ |
342 |
|
public void testTimedOffer() throws InterruptedException { |
343 |
|
final LinkedBlockingQueue q = new LinkedBlockingQueue(2); |
344 |
< |
Thread t = new ThreadShouldThrow(InterruptedException.class) { |
344 |
> |
Thread t = new Thread(new CheckedRunnable() { |
345 |
|
public void realRun() throws InterruptedException { |
346 |
|
q.put(new Object()); |
347 |
|
q.put(new Object()); |
348 |
< |
threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS, MILLISECONDS)); |
349 |
< |
q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS); |
350 |
< |
}}; |
348 |
> |
assertFalse(q.offer(new Object(), SHORT_DELAY_MS, MILLISECONDS)); |
349 |
> |
try { |
350 |
> |
q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS); |
351 |
> |
shouldThrow(); |
352 |
> |
} catch (InterruptedException success) {} |
353 |
> |
}}); |
354 |
|
|
355 |
|
t.start(); |
356 |
|
Thread.sleep(SMALL_DELAY_MS); |