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

Comparing jsr166/src/test/tck/ArrayBlockingQueueTest.java (file contents):
Revision 1.41 by jsr166, Fri Nov 5 00:17:22 2010 UTC vs.
Revision 1.42 by jsr166, Sun Nov 28 08:43:53 2010 UTC

# Line 453 | Line 453 | public class ArrayBlockingQueueTest exte
453       * returning timeout status
454       */
455      public void testInterruptedTimedPoll() throws InterruptedException {
456 <        Thread t = new Thread(new CheckedRunnable() {
456 >        final BlockingQueue<Integer> q = populatedQueue(SIZE);
457 >        final CountDownLatch aboutToWait = new CountDownLatch(1);
458 >        Thread t = newStartedThread(new CheckedRunnable() {
459              public void realRun() throws InterruptedException {
458                ArrayBlockingQueue q = populatedQueue(SIZE);
460                  for (int i = 0; i < SIZE; ++i) {
461 <                    assertEquals(i, q.poll(SHORT_DELAY_MS, MILLISECONDS));;
461 >                    long t0 = System.nanoTime();
462 >                    assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
463 >                    assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
464                  }
465 +                long t0 = System.nanoTime();
466 +                aboutToWait.countDown();
467                  try {
468 <                    q.poll(SMALL_DELAY_MS, MILLISECONDS);
468 >                    q.poll(MEDIUM_DELAY_MS, MILLISECONDS);
469                      shouldThrow();
470 <                } catch (InterruptedException success) {}
470 >                } catch (InterruptedException success) {
471 >                    assertTrue(millisElapsedSince(t0) < MEDIUM_DELAY_MS);
472 >                }
473              }});
474  
475 <        t.start();
476 <        Thread.sleep(SHORT_DELAY_MS);
475 >        aboutToWait.await();
476 >        waitForThreadToEnterWaitState(t, SMALL_DELAY_MS);
477          t.interrupt();
478 <        t.join();
478 >        awaitTermination(t, MEDIUM_DELAY_MS);
479 >        checkEmpty(q);
480      }
481  
482      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines