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.45 by dl, Fri May 6 11:22:07 2011 UTC vs.
Revision 1.46 by jsr166, Sat May 21 06:24:33 2011 UTC

# Line 365 | Line 365 | public class ArrayBlockingQueueTest exte
365       */
366      public void testTimedOffer() throws InterruptedException {
367          final ArrayBlockingQueue q = new ArrayBlockingQueue(2);
368 <        Thread t = new Thread(new CheckedRunnable() {
368 >        final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
369 >        Thread t = newStartedThread(new CheckedRunnable() {
370              public void realRun() throws InterruptedException {
371                  q.put(new Object());
372                  q.put(new Object());
373 <                assertFalse(q.offer(new Object(), SHORT_DELAY_MS/2, MILLISECONDS));
373 >                long startTime = System.nanoTime();
374 >                assertFalse(q.offer(new Object(), timeoutMillis(), MILLISECONDS));
375 >                assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
376 >                pleaseInterrupt.countDown();
377                  try {
378 <                    q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS);
378 >                    q.offer(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS);
379                      shouldThrow();
380                  } catch (InterruptedException success) {}
381              }});
382  
383 <        t.start();
380 <        delay(SHORT_DELAY_MS);
383 >        await(pleaseInterrupt);
384          t.interrupt();
385 <        t.join();
385 >        awaitTermination(t);
386      }
387  
388      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines