350 |
|
*/ |
351 |
|
public void testTimedOffer() throws InterruptedException { |
352 |
|
final ArrayBlockingQueue q = new ArrayBlockingQueue(2); |
353 |
< |
Thread t = new ThreadShouldThrow(InterruptedException.class) { |
353 |
> |
Thread t = new Thread(new CheckedRunnable() { |
354 |
|
public void realRun() throws InterruptedException { |
355 |
|
q.put(new Object()); |
356 |
|
q.put(new Object()); |
357 |
< |
threadAssertFalse(q.offer(new Object(), SHORT_DELAY_MS/2, MILLISECONDS)); |
358 |
< |
q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS); |
359 |
< |
}}; |
357 |
> |
assertFalse(q.offer(new Object(), SHORT_DELAY_MS/2, MILLISECONDS)); |
358 |
> |
try { |
359 |
> |
q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS); |
360 |
> |
shouldThrow(); |
361 |
> |
} catch (InterruptedException success) {} |
362 |
> |
}}); |
363 |
|
|
364 |
|
t.start(); |
365 |
|
Thread.sleep(SHORT_DELAY_MS); |