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

Comparing jsr166/src/test/tck/LinkedTransferQueueTest.java (file contents):
Revision 1.62 by jsr166, Sun Jun 14 20:58:14 2015 UTC vs.
Revision 1.63 by jsr166, Sun Oct 4 18:49:02 2015 UTC

# Line 596 | Line 596 | public class LinkedTransferQueueTest ext
596      public void testOfferInExecutor() {
597          final LinkedTransferQueue q = new LinkedTransferQueue();
598          final CheckedBarrier threadsStarted = new CheckedBarrier(2);
599 <        ExecutorService executor = Executors.newFixedThreadPool(2);
599 >        final ExecutorService executor = Executors.newFixedThreadPool(2);
600 >        try (PoolCleaner cleaner = cleaner(executor)) {
601  
602 <        executor.execute(new CheckedRunnable() {
603 <            public void realRun() throws InterruptedException {
604 <                threadsStarted.await();
605 <                assertTrue(q.offer(one, LONG_DELAY_MS, MILLISECONDS));
606 <            }});
607 <
608 <        executor.execute(new CheckedRunnable() {
609 <            public void realRun() throws InterruptedException {
610 <                threadsStarted.await();
611 <                assertSame(one, q.take());
612 <                checkEmpty(q);
613 <            }});
614 <
614 <        joinPool(executor);
602 >            executor.execute(new CheckedRunnable() {
603 >                public void realRun() throws InterruptedException {
604 >                    threadsStarted.await();
605 >                    assertTrue(q.offer(one, LONG_DELAY_MS, MILLISECONDS));
606 >                }});
607 >
608 >            executor.execute(new CheckedRunnable() {
609 >                public void realRun() throws InterruptedException {
610 >                    threadsStarted.await();
611 >                    assertSame(one, q.take());
612 >                    checkEmpty(q);
613 >                }});
614 >        }
615      }
616  
617      /**
# Line 620 | Line 620 | public class LinkedTransferQueueTest ext
620      public void testPollInExecutor() {
621          final LinkedTransferQueue q = new LinkedTransferQueue();
622          final CheckedBarrier threadsStarted = new CheckedBarrier(2);
623 <        ExecutorService executor = Executors.newFixedThreadPool(2);
624 <
625 <        executor.execute(new CheckedRunnable() {
626 <            public void realRun() throws InterruptedException {
627 <                assertNull(q.poll());
628 <                threadsStarted.await();
629 <                assertSame(one, q.poll(LONG_DELAY_MS, MILLISECONDS));
630 <                checkEmpty(q);
631 <            }});
632 <
633 <        executor.execute(new CheckedRunnable() {
634 <            public void realRun() throws InterruptedException {
635 <                threadsStarted.await();
636 <                q.put(one);
637 <            }});
623 >        final ExecutorService executor = Executors.newFixedThreadPool(2);
624 >        try (PoolCleaner cleaner = cleaner(executor)) {
625  
626 <        joinPool(executor);
626 >            executor.execute(new CheckedRunnable() {
627 >                public void realRun() throws InterruptedException {
628 >                    assertNull(q.poll());
629 >                    threadsStarted.await();
630 >                    assertSame(one, q.poll(LONG_DELAY_MS, MILLISECONDS));
631 >                    checkEmpty(q);
632 >                }});
633 >
634 >            executor.execute(new CheckedRunnable() {
635 >                public void realRun() throws InterruptedException {
636 >                    threadsStarted.await();
637 >                    q.put(one);
638 >                }});
639 >        }
640      }
641  
642      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines