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

Comparing jsr166/src/test/tck/LinkedBlockingDequeTest.java (file contents):
Revision 1.33 by jsr166, Thu Nov 18 20:21:53 2010 UTC vs.
Revision 1.34 by jsr166, Sun Nov 28 08:43:53 2010 UTC

# Line 743 | Line 743 | public class LinkedBlockingDequeTest ext
743       * returning timeout status
744       */
745      public void testInterruptedTimedPoll() throws InterruptedException {
746 <        Thread t = new Thread(new CheckedRunnable() {
746 >        final BlockingQueue<Integer> q = populatedDeque(SIZE);
747 >        final CountDownLatch aboutToWait = new CountDownLatch(1);
748 >        Thread t = newStartedThread(new CheckedRunnable() {
749              public void realRun() throws InterruptedException {
748                LinkedBlockingDeque q = populatedDeque(SIZE);
750                  for (int i = 0; i < SIZE; ++i) {
751 <                    assertEquals(i, q.poll(SHORT_DELAY_MS, MILLISECONDS));
751 >                    long t0 = System.nanoTime();
752 >                    assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
753 >                    assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
754                  }
755 +                long t0 = System.nanoTime();
756 +                aboutToWait.countDown();
757                  try {
758 <                    q.poll(SMALL_DELAY_MS, MILLISECONDS);
758 >                    q.poll(MEDIUM_DELAY_MS, MILLISECONDS);
759                      shouldThrow();
760 <                } catch (InterruptedException success) {}
760 >                } catch (InterruptedException success) {
761 >                    assertTrue(millisElapsedSince(t0) < MEDIUM_DELAY_MS);
762 >                }
763              }});
764  
765 <        t.start();
766 <        Thread.sleep(SHORT_DELAY_MS);
765 >        aboutToWait.await();
766 >        waitForThreadToEnterWaitState(t, SMALL_DELAY_MS);
767          t.interrupt();
768 <        t.join();
768 >        awaitTermination(t, MEDIUM_DELAY_MS);
769 >        checkEmpty(q);
770      }
771  
772      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines