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

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

# Line 722 | Line 722 | public class LinkedBlockingQueueTest ext
722          final LinkedBlockingQueue q = new LinkedBlockingQueue(2);
723          q.add(one);
724          q.add(two);
725        ExecutorService executor = Executors.newFixedThreadPool(2);
725          final CheckedBarrier threadsStarted = new CheckedBarrier(2);
726 <        executor.execute(new CheckedRunnable() {
727 <            public void realRun() throws InterruptedException {
728 <                assertFalse(q.offer(three));
729 <                threadsStarted.await();
730 <                assertTrue(q.offer(three, LONG_DELAY_MS, MILLISECONDS));
731 <                assertEquals(0, q.remainingCapacity());
732 <            }});
733 <
734 <        executor.execute(new CheckedRunnable() {
735 <            public void realRun() throws InterruptedException {
736 <                threadsStarted.await();
737 <                assertSame(one, q.take());
738 <            }});
739 <
740 <        joinPool(executor);
726 >        final ExecutorService executor = Executors.newFixedThreadPool(2);
727 >        try (PoolCleaner cleaner = cleaner(executor)) {
728 >            executor.execute(new CheckedRunnable() {
729 >                public void realRun() throws InterruptedException {
730 >                    assertFalse(q.offer(three));
731 >                    threadsStarted.await();
732 >                    assertTrue(q.offer(three, LONG_DELAY_MS, MILLISECONDS));
733 >                    assertEquals(0, q.remainingCapacity());
734 >                }});
735 >
736 >            executor.execute(new CheckedRunnable() {
737 >                public void realRun() throws InterruptedException {
738 >                    threadsStarted.await();
739 >                    assertSame(one, q.take());
740 >                }});
741 >        }
742      }
743  
744      /**
# Line 747 | Line 747 | public class LinkedBlockingQueueTest ext
747      public void testPollInExecutor() {
748          final LinkedBlockingQueue q = new LinkedBlockingQueue(2);
749          final CheckedBarrier threadsStarted = new CheckedBarrier(2);
750 <        ExecutorService executor = Executors.newFixedThreadPool(2);
751 <        executor.execute(new CheckedRunnable() {
752 <            public void realRun() throws InterruptedException {
753 <                assertNull(q.poll());
754 <                threadsStarted.await();
755 <                assertSame(one, q.poll(LONG_DELAY_MS, MILLISECONDS));
756 <                checkEmpty(q);
757 <            }});
758 <
759 <        executor.execute(new CheckedRunnable() {
760 <            public void realRun() throws InterruptedException {
761 <                threadsStarted.await();
762 <                q.put(one);
763 <            }});
764 <
765 <        joinPool(executor);
750 >        final ExecutorService executor = Executors.newFixedThreadPool(2);
751 >        try (PoolCleaner cleaner = cleaner(executor)) {
752 >            executor.execute(new CheckedRunnable() {
753 >                public void realRun() throws InterruptedException {
754 >                    assertNull(q.poll());
755 >                    threadsStarted.await();
756 >                    assertSame(one, q.poll(LONG_DELAY_MS, MILLISECONDS));
757 >                    checkEmpty(q);
758 >                }});
759 >
760 >            executor.execute(new CheckedRunnable() {
761 >                public void realRun() throws InterruptedException {
762 >                    threadsStarted.await();
763 >                    q.put(one);
764 >                }});
765 >        }
766      }
767  
768      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines