ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/DelayQueueTest.java
(Generate patch)

Comparing jsr166/src/test/tck/DelayQueueTest.java (file contents):
Revision 1.39 by jsr166, Tue Oct 19 00:43:49 2010 UTC vs.
Revision 1.40 by jsr166, Thu Oct 28 17:57:26 2010 UTC

# Line 391 | Line 391 | public class DelayQueueTest extends JSR1
391      /**
392       * take blocks interruptibly when empty
393       */
394 <    public void testTakeFromEmpty() throws InterruptedException {
395 <        final DelayQueue q = new DelayQueue();
396 <        Thread t = new ThreadShouldThrow(InterruptedException.class) {
397 <            public void realRun() throws InterruptedException {
398 <                q.take();
399 <            }};
400 <
401 <        t.start();
394 >    public void testTakeFromEmptyBlocksInterruptibly()
395 >            throws InterruptedException {
396 >        final BlockingQueue q = new DelayQueue();
397 >        final CountDownLatch threadStarted = new CountDownLatch(1);
398 >        Thread t = newStartedThread(new CheckedRunnable() {
399 >            public void realRun() {
400 >                long t0 = System.nanoTime();
401 >                threadStarted.countDown();
402 >                try {
403 >                    q.take();
404 >                    shouldThrow();
405 >                } catch (InterruptedException expected) {}
406 >                assertTrue(millisElapsedSince(t0) >= SHORT_DELAY_MS);
407 >            }});
408 >        threadStarted.await();
409          Thread.sleep(SHORT_DELAY_MS);
410 +        assertTrue(t.isAlive());
411          t.interrupt();
412 <        t.join();
412 >        awaitTermination(t, MEDIUM_DELAY_MS);
413 >        assertFalse(t.isAlive());
414      }
415  
416      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines