[cvs] / jsr166 / src / test / tck / ArrayBlockingQueueTest.java Repository:
ViewVC logotype

Diff of /jsr166/src/test/tck/ArrayBlockingQueueTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.41, Fri Nov 5 00:17:22 2010 UTC revision 1.42, Sun Nov 28 08:43:53 2010 UTC
# Line 453  Line 453 
453       * returning timeout status       * returning timeout status
454       */       */
455      public void testInterruptedTimedPoll() throws InterruptedException {      public void testInterruptedTimedPoll() throws InterruptedException {
456          Thread t = new Thread(new CheckedRunnable() {          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 {              public void realRun() throws InterruptedException {
                 ArrayBlockingQueue q = populatedQueue(SIZE);  
460                  for (int i = 0; i < SIZE; ++i) {                  for (int i = 0; i < SIZE; ++i) {
461                      assertEquals(i, q.poll(SHORT_DELAY_MS, MILLISECONDS));;                      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 {                  try {
468                      q.poll(SMALL_DELAY_MS, MILLISECONDS);                      q.poll(MEDIUM_DELAY_MS, MILLISECONDS);
469                      shouldThrow();                      shouldThrow();
470                  } catch (InterruptedException success) {}                  } catch (InterruptedException success) {
471                        assertTrue(millisElapsedSince(t0) < MEDIUM_DELAY_MS);
472                    }
473              }});              }});
474    
475          t.start();          aboutToWait.await();
476          Thread.sleep(SHORT_DELAY_MS);          waitForThreadToEnterWaitState(t, SMALL_DELAY_MS);
477          t.interrupt();          t.interrupt();
478          t.join();          awaitTermination(t, MEDIUM_DELAY_MS);
479            checkEmpty(q);
480      }      }
481    
482      /**      /**

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.42

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8