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

Comparing jsr166/src/test/tck/BlockingQueueTest.java (file contents):
Revision 1.23 by jsr166, Sun Aug 11 22:29:26 2019 UTC vs.
Revision 1.24 by jsr166, Thu Sep 5 21:30:59 2019 UTC

# Line 298 | Line 298 | public abstract class BlockingQueueTest
298       */
299      public void testTimedPollFromEmptyBlocksInterruptibly() {
300          final BlockingQueue q = emptyCollection();
301 <        final CountDownLatch threadStarted = new CountDownLatch(1);
301 >        final CountDownLatch pleaseInterrupt = new CountDownLatch(1);
302          Thread t = newStartedThread(new CheckedRunnable() {
303              public void realRun() {
304 <                threadStarted.countDown();
305 <                long startTime = System.nanoTime();
306 <
304 >                pleaseInterrupt.countDown();
305                  try {
306 <                    q.poll(LONG_DELAY_MS, MILLISECONDS);
306 >                    q.poll(LONGER_DELAY_MS, MILLISECONDS);
307                      shouldThrow();
308                  } catch (InterruptedException success) {}
309                  assertFalse(Thread.interrupted());
312
313                assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
310              }});
311  
312 <        await(threadStarted);
313 <        if (randomBoolean())  assertThreadBlocks(t, Thread.State.TIMED_WAITING);
312 >        await(pleaseInterrupt);
313 >        if (randomBoolean()) assertThreadBlocks(t, Thread.State.TIMED_WAITING);
314          t.interrupt();
315          awaitTermination(t);
316      }
# Line 327 | Line 323 | public abstract class BlockingQueueTest
323          final BlockingQueue q = emptyCollection();
324          Thread t = newStartedThread(new CheckedRunnable() {
325              public void realRun() {
330                long startTime = System.nanoTime();
331
326                  Thread.currentThread().interrupt();
327                  try {
328 <                    q.poll(LONG_DELAY_MS, MILLISECONDS);
328 >                    q.poll(LONGER_DELAY_MS, MILLISECONDS);
329                      shouldThrow();
330                  } catch (InterruptedException success) {}
331                  assertFalse(Thread.interrupted());
338
339                assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
332              }});
333  
334          awaitTermination(t);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines