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

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

# Line 441 | Line 441 | public class LinkedBlockingQueueTest ext
441       * returning timeout status
442       */
443      public void testInterruptedTimedPoll() throws InterruptedException {
444 <        Thread t = new Thread(new CheckedRunnable() {
444 >        final BlockingQueue<Integer> q = populatedQueue(SIZE);
445 >        final CountDownLatch aboutToWait = new CountDownLatch(1);
446 >        Thread t = newStartedThread(new CheckedRunnable() {
447              public void realRun() throws InterruptedException {
446                LinkedBlockingQueue q = populatedQueue(SIZE);
448                  for (int i = 0; i < SIZE; ++i) {
449 <                    assertEquals(i, q.poll(SHORT_DELAY_MS, MILLISECONDS));
449 >                    long t0 = System.nanoTime();
450 >                    assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
451 >                    assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
452                  }
453 +                long t0 = System.nanoTime();
454 +                aboutToWait.countDown();
455                  try {
456 <                    q.poll(SMALL_DELAY_MS, MILLISECONDS);
456 >                    q.poll(MEDIUM_DELAY_MS, MILLISECONDS);
457                      shouldThrow();
458 <                } catch (InterruptedException success) {}
458 >                } catch (InterruptedException success) {
459 >                    assertTrue(millisElapsedSince(t0) < MEDIUM_DELAY_MS);
460 >                }
461              }});
462  
463 <        t.start();
464 <        Thread.sleep(SHORT_DELAY_MS);
463 >        aboutToWait.await();
464 >        waitForThreadToEnterWaitState(t, SMALL_DELAY_MS);
465          t.interrupt();
466 <        t.join();
466 >        awaitTermination(t, MEDIUM_DELAY_MS);
467 >        checkEmpty(q);
468      }
469  
470      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines