332 |
|
public void realRun() { |
333 |
|
q.put(new Integer(0)); |
334 |
|
q.put(new Integer(0)); |
335 |
< |
threadAssertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, MILLISECONDS)); |
336 |
< |
threadAssertTrue(q.offer(new Integer(0), LONG_DELAY_MS, MILLISECONDS)); |
335 |
> |
assertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, MILLISECONDS)); |
336 |
> |
assertTrue(q.offer(new Integer(0), LONG_DELAY_MS, MILLISECONDS)); |
337 |
|
}}); |
338 |
|
|
339 |
|
t.start(); |
372 |
|
* Take removes existing elements until empty, then blocks interruptibly |
373 |
|
*/ |
374 |
|
public void testBlockingTake() throws InterruptedException { |
375 |
< |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
375 |
> |
final PriorityBlockingQueue q = populatedQueue(SIZE); |
376 |
> |
Thread t = new Thread(new CheckedRunnable() { |
377 |
|
public void realRun() throws InterruptedException { |
377 |
– |
PriorityBlockingQueue q = populatedQueue(SIZE); |
378 |
|
for (int i = 0; i < SIZE; ++i) { |
379 |
< |
threadAssertEquals(i, ((Integer)q.take()).intValue()); |
379 |
> |
assertEquals(i, q.take()); |
380 |
|
} |
381 |
< |
q.take(); |
381 |
> |
try { |
382 |
> |
q.take(); |
383 |
> |
shouldThrow(); |
384 |
> |
} catch (InterruptedException success) {} |
385 |
|
}}); |
386 |
|
|
387 |
|
t.start(); |
456 |
|
Thread t = new Thread(new CheckedRunnable() { |
457 |
|
public void realRun() throws InterruptedException { |
458 |
|
assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); |
459 |
< |
assertEquals(0, q.poll(MEDIUM_DELAY_MS, MILLISECONDS)); |
459 |
> |
assertSame(zero, q.poll(MEDIUM_DELAY_MS, MILLISECONDS)); |
460 |
|
try { |
461 |
|
q.poll(LONG_DELAY_MS, MILLISECONDS); |
462 |
< |
threadShouldThrow(); |
462 |
> |
shouldThrow(); |
463 |
|
} catch (InterruptedException success) {} |
464 |
|
}}); |
465 |
|
|
466 |
|
t.start(); |
467 |
|
Thread.sleep(SMALL_DELAY_MS); |
468 |
< |
assertTrue(q.offer(new Integer(0), SHORT_DELAY_MS, MILLISECONDS)); |
468 |
> |
assertTrue(q.offer(zero, SHORT_DELAY_MS, MILLISECONDS)); |
469 |
|
t.interrupt(); |
470 |
|
t.join(); |
471 |
|
} |