415 |
|
* Take removes existing elements until empty, then blocks interruptibly |
416 |
|
*/ |
417 |
|
public void testBlockingTake() throws InterruptedException { |
418 |
< |
Thread t = new ThreadShouldThrow(InterruptedException.class) { |
418 |
> |
final DelayQueue q = populatedQueue(SIZE); |
419 |
> |
Thread t = new Thread(new CheckedRunnable() { |
420 |
|
public void realRun() throws InterruptedException { |
420 |
– |
DelayQueue q = populatedQueue(SIZE); |
421 |
|
for (int i = 0; i < SIZE; ++i) { |
422 |
< |
threadAssertEquals(new PDelay(i), ((PDelay)q.take())); |
422 |
> |
assertEquals(new PDelay(i), ((PDelay)q.take())); |
423 |
|
} |
424 |
< |
q.take(); |
425 |
< |
}}; |
424 |
> |
try { |
425 |
> |
q.take(); |
426 |
> |
shouldThrow(); |
427 |
> |
} catch (InterruptedException success) {} |
428 |
> |
}}); |
429 |
|
|
430 |
|
t.start(); |
431 |
|
Thread.sleep(SHORT_DELAY_MS); |