[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.85, Sat May 13 22:49:01 2017 UTC revision 1.86, Sun May 14 00:48:20 2017 UTC
# Line 493  Line 493 
493       */       */
494      public void testInterruptedTimedPoll() throws InterruptedException {      public void testInterruptedTimedPoll() throws InterruptedException {
495          final BlockingQueue<Integer> q = populatedQueue(SIZE);          final BlockingQueue<Integer> q = populatedQueue(SIZE);
496          final CountDownLatch aboutToWait = new CountDownLatch(1);          final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
497          Thread t = newStartedThread(new CheckedRunnable() {          Thread t = newStartedThread(new CheckedRunnable() {
498              public void realRun() throws InterruptedException {              public void realRun() throws InterruptedException {
499                  long startTime = System.nanoTime();                  long startTime = System.nanoTime();
500                  for (int i = 0; i < SIZE; ++i) {                  for (int i = 0; i < SIZE; ++i) {
501                      assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));                      assertEquals(i, (int) q.poll(LONG_DELAY_MS, MILLISECONDS));
502                  }                  }
503                  aboutToWait.countDown();  
504                    pleaseInterrupt.countDown();
505                  try {                  try {
506                      q.poll(LONG_DELAY_MS, MILLISECONDS);                      q.poll(LONG_DELAY_MS, MILLISECONDS);
507                      shouldThrow();                      shouldThrow();
508                  } catch (InterruptedException success) {                  } catch (InterruptedException success) {}
509                    assertFalse(Thread.interrupted());
510    
511                      assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);                      assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
                 }  
512              }});              }});
513    
514          await(aboutToWait);          await(pleaseInterrupt);
515          assertThreadBlocks(t, Thread.State.TIMED_WAITING);          assertThreadBlocks(t, Thread.State.TIMED_WAITING);
516          t.interrupt();          t.interrupt();
517          awaitTermination(t);          awaitTermination(t);

Legend:
Removed from v.1.85  
changed lines
  Added in v.1.86

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8