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

Comparing jsr166/src/test/tck/SynchronousQueueTest.java (file contents):
Revision 1.31 by jsr166, Tue Mar 15 19:47:07 2011 UTC vs.
Revision 1.34 by jsr166, Sat May 21 06:24:33 2011 UTC

# Line 159 | Line 159 | public class SynchronousQueueTest extend
159              q.put(null);
160              shouldThrow();
161          } catch (NullPointerException success) {}
162 <     }
162 >    }
163  
164      /**
165       * put blocks interruptibly if no active taker
# Line 172 | Line 172 | public class SynchronousQueueTest extend
172              }});
173  
174          t.start();
175 <        Thread.sleep(SHORT_DELAY_MS);
175 >        delay(SHORT_DELAY_MS);
176          t.interrupt();
177          t.join();
178      }
# Line 196 | Line 196 | public class SynchronousQueueTest extend
196              }});
197  
198          t.start();
199 <        Thread.sleep(SHORT_DELAY_MS);
199 >        delay(SHORT_DELAY_MS);
200          assertEquals(0, q.take());
201 <        Thread.sleep(SHORT_DELAY_MS);
201 >        delay(SHORT_DELAY_MS);
202          t.interrupt();
203          t.join();
204      }
# Line 211 | Line 211 | public class SynchronousQueueTest extend
211          final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
212          Thread t = newStartedThread(new CheckedRunnable() {
213              public void realRun() throws InterruptedException {
214 <                long t0 = System.nanoTime();
215 <                assertFalse(q.offer(new Object(), SHORT_DELAY_MS, MILLISECONDS));
216 <                assertTrue(millisElapsedSince(t0) >= SHORT_DELAY_MS);
214 >                long startTime = System.nanoTime();
215 >                assertFalse(q.offer(new Object(), timeoutMillis(), MILLISECONDS));
216 >                assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
217                  pleaseInterrupt.countDown();
218                t0 = System.nanoTime();
218                  try {
219 <                    q.offer(new Object(), LONG_DELAY_MS, MILLISECONDS);
219 >                    q.offer(new Object(), 2 * LONG_DELAY_MS, MILLISECONDS);
220                      shouldThrow();
221                  } catch (InterruptedException success) {}
223                assertTrue(millisElapsedSince(t0) < MEDIUM_DELAY_MS);
222              }});
223  
224 <        assertTrue(pleaseInterrupt.await(MEDIUM_DELAY_MS, MILLISECONDS));
224 >        await(pleaseInterrupt);
225          t.interrupt();
226 <        awaitTermination(t, MEDIUM_DELAY_MS);
226 >        awaitTermination(t);
227      }
228  
229      /**
# Line 253 | Line 251 | public class SynchronousQueueTest extend
251              }});
252  
253          t.start();
254 <        Thread.sleep(SHORT_DELAY_MS);
254 >        delay(SHORT_DELAY_MS);
255          t.interrupt();
256          t.join();
257      }
# Line 277 | Line 275 | public class SynchronousQueueTest extend
275              }});
276  
277          t.start();
278 <        Thread.sleep(SHORT_DELAY_MS);
278 >        delay(SHORT_DELAY_MS);
279          assertEquals(0, q.take());
280 <        Thread.sleep(SHORT_DELAY_MS);
280 >        delay(SHORT_DELAY_MS);
281          t.interrupt();
282          t.join();
283      }
# Line 295 | Line 293 | public class SynchronousQueueTest extend
293              }});
294  
295          t.start();
296 <        Thread.sleep(SHORT_DELAY_MS);
296 >        delay(SHORT_DELAY_MS);
297          t.interrupt();
298          t.join();
299      }
# Line 346 | Line 344 | public class SynchronousQueueTest extend
344              }});
345  
346          threadStarted.await();
347 <        Thread.sleep(SHORT_DELAY_MS);
347 >        delay(SHORT_DELAY_MS);
348          t.interrupt();
349          awaitTermination(t, MEDIUM_DELAY_MS);
350      }
# Line 573 | Line 571 | public class SynchronousQueueTest extend
571  
572          executor.execute(new CheckedRunnable() {
573              public void realRun() throws InterruptedException {
574 <                Thread.sleep(SMALL_DELAY_MS);
574 >                delay(SMALL_DELAY_MS);
575                  assertSame(one, q.take());
576              }});
577  
# Line 595 | Line 593 | public class SynchronousQueueTest extend
593  
594          executor.execute(new CheckedRunnable() {
595              public void realRun() throws InterruptedException {
596 <                Thread.sleep(SHORT_DELAY_MS);
596 >                delay(SHORT_DELAY_MS);
597                  q.put(one);
598              }});
599  
# Line 665 | Line 663 | public class SynchronousQueueTest extend
663  
664          t.start();
665          ArrayList l = new ArrayList();
666 <        Thread.sleep(SHORT_DELAY_MS);
666 >        delay(SHORT_DELAY_MS);
667          q.drainTo(l);
668          assertTrue(l.size() <= 1);
669          if (l.size() > 0)
# Line 714 | Line 712 | public class SynchronousQueueTest extend
712          t1.start();
713          t2.start();
714          ArrayList l = new ArrayList();
715 <        Thread.sleep(SHORT_DELAY_MS);
715 >        delay(SHORT_DELAY_MS);
716          q.drainTo(l, 1);
717          assertEquals(1, l.size());
718          q.drainTo(l, 1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines