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

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

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

revision 1.2, Thu Oct 28 17:57:26 2010 UTC revision 1.3, Fri Oct 29 07:00:32 2010 UTC
# Line 72  Line 72 
72      }      }
73    
74      /**      /**
75       * take blocks interruptibly when empty       * take() blocks interruptibly when empty
76       */       */
77      public void testTakeFromEmptyBlocksInterruptibly()      public void testTakeFromEmptyBlocksInterruptibly()
78              throws InterruptedException {              throws InterruptedException {
# Line 88  Line 88 
88                  } catch (InterruptedException success) {}                  } catch (InterruptedException success) {}
89                  assertTrue(millisElapsedSince(t0) >= SHORT_DELAY_MS);                  assertTrue(millisElapsedSince(t0) >= SHORT_DELAY_MS);
90              }});              }});
91    
92          threadStarted.await();          threadStarted.await();
93          Thread.sleep(SHORT_DELAY_MS);          Thread.sleep(SHORT_DELAY_MS);
94          assertTrue(t.isAlive());          assertTrue(t.isAlive());
95          t.interrupt();          t.interrupt();
96          awaitTermination(t, MEDIUM_DELAY_MS);          awaitTermination(t, MEDIUM_DELAY_MS);
97          assertFalse(t.isAlive());      }
98    
99        /**
100         * take() throws InterruptedException immediately if interrupted
101         * before waiting
102         */
103        public void testTakeFromEmptyAfterInterrupt()
104                throws InterruptedException {
105            final BlockingQueue q = emptyCollection();
106            Thread t = newStartedThread(new CheckedRunnable() {
107                public void realRun() {
108                    long t0 = System.nanoTime();
109                    Thread.currentThread().interrupt();
110                    try {
111                        q.take();
112                        shouldThrow();
113                    } catch (InterruptedException success) {}
114                    assertTrue(millisElapsedSince(t0) < SHORT_DELAY_MS);
115                }});
116    
117            awaitTermination(t, MEDIUM_DELAY_MS);
118      }      }
119    
120      /** For debugging. */      /** For debugging. */

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8