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

Comparing jsr166/src/test/tck/DelayQueueTest.java (file contents):
Revision 1.73 by jsr166, Sat May 23 00:53:08 2015 UTC vs.
Revision 1.75 by jsr166, Sun Oct 4 18:49:02 2015 UTC

# Line 124 | Line 124 | public class DelayQueueTest extends JSR1
124      private DelayQueue<PDelay> populatedQueue(int n) {
125          DelayQueue<PDelay> q = new DelayQueue<PDelay>();
126          assertTrue(q.isEmpty());
127 <        for (int i = n-1; i >= 0; i -= 2)
127 >        for (int i = n - 1; i >= 0; i -= 2)
128              assertTrue(q.offer(new PDelay(i)));
129          for (int i = (n & 1); i < n; i += 2)
130              assertTrue(q.offer(new PDelay(i)));
# Line 653 | Line 653 | public class DelayQueueTest extends JSR1
653      public void testPollInExecutor() {
654          final DelayQueue q = new DelayQueue();
655          final CheckedBarrier threadsStarted = new CheckedBarrier(2);
656 <        ExecutorService executor = Executors.newFixedThreadPool(2);
657 <        executor.execute(new CheckedRunnable() {
658 <            public void realRun() throws InterruptedException {
659 <                assertNull(q.poll());
660 <                threadsStarted.await();
661 <                assertNotNull(q.poll(LONG_DELAY_MS, MILLISECONDS));
662 <                checkEmpty(q);
663 <            }});
664 <
665 <        executor.execute(new CheckedRunnable() {
666 <            public void realRun() throws InterruptedException {
667 <                threadsStarted.await();
668 <                q.put(new PDelay(1));
669 <            }});
670 <
671 <        joinPool(executor);
656 >        final ExecutorService executor = Executors.newFixedThreadPool(2);
657 >        try (PoolCleaner cleaner = cleaner(executor)) {
658 >            executor.execute(new CheckedRunnable() {
659 >                public void realRun() throws InterruptedException {
660 >                    assertNull(q.poll());
661 >                    threadsStarted.await();
662 >                    assertNotNull(q.poll(LONG_DELAY_MS, MILLISECONDS));
663 >                    checkEmpty(q);
664 >                }});
665 >
666 >            executor.execute(new CheckedRunnable() {
667 >                public void realRun() throws InterruptedException {
668 >                    threadsStarted.await();
669 >                    q.put(new PDelay(1));
670 >                }});
671 >        }
672      }
673  
674      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines