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

Comparing jsr166/src/test/tck/ArrayBlockingQueueTest.java (file contents):
Revision 1.67 by jsr166, Sun May 24 01:23:17 2015 UTC vs.
Revision 1.68 by jsr166, Sun Oct 4 18:49:02 2015 UTC

# Line 788 | Line 788 | public class ArrayBlockingQueueTest exte
788          final ArrayBlockingQueue q = new ArrayBlockingQueue(2);
789          q.add(one);
790          q.add(two);
791        ExecutorService executor = Executors.newFixedThreadPool(2);
791          final CheckedBarrier threadsStarted = new CheckedBarrier(2);
792 <        executor.execute(new CheckedRunnable() {
793 <            public void realRun() throws InterruptedException {
794 <                assertFalse(q.offer(three));
795 <                threadsStarted.await();
796 <                assertTrue(q.offer(three, LONG_DELAY_MS, MILLISECONDS));
797 <                assertEquals(0, q.remainingCapacity());
798 <            }});
799 <
800 <        executor.execute(new CheckedRunnable() {
801 <            public void realRun() throws InterruptedException {
802 <                threadsStarted.await();
803 <                assertEquals(0, q.remainingCapacity());
804 <                assertSame(one, q.take());
805 <            }});
806 <
807 <        joinPool(executor);
792 >        final ExecutorService executor = Executors.newFixedThreadPool(2);
793 >        try (PoolCleaner cleaner = cleaner(executor)) {
794 >            executor.execute(new CheckedRunnable() {
795 >                public void realRun() throws InterruptedException {
796 >                    assertFalse(q.offer(three));
797 >                    threadsStarted.await();
798 >                    assertTrue(q.offer(three, LONG_DELAY_MS, MILLISECONDS));
799 >                    assertEquals(0, q.remainingCapacity());
800 >                }});
801 >
802 >            executor.execute(new CheckedRunnable() {
803 >                public void realRun() throws InterruptedException {
804 >                    threadsStarted.await();
805 >                    assertEquals(0, q.remainingCapacity());
806 >                    assertSame(one, q.take());
807 >                }});
808 >        }
809      }
810  
811      /**
# Line 814 | Line 814 | public class ArrayBlockingQueueTest exte
814      public void testPollInExecutor() {
815          final ArrayBlockingQueue q = new ArrayBlockingQueue(2);
816          final CheckedBarrier threadsStarted = new CheckedBarrier(2);
817 <        ExecutorService executor = Executors.newFixedThreadPool(2);
818 <        executor.execute(new CheckedRunnable() {
819 <            public void realRun() throws InterruptedException {
820 <                assertNull(q.poll());
821 <                threadsStarted.await();
822 <                assertSame(one, q.poll(LONG_DELAY_MS, MILLISECONDS));
823 <                checkEmpty(q);
824 <            }});
825 <
826 <        executor.execute(new CheckedRunnable() {
827 <            public void realRun() throws InterruptedException {
828 <                threadsStarted.await();
829 <                q.put(one);
830 <            }});
831 <
832 <        joinPool(executor);
817 >        final ExecutorService executor = Executors.newFixedThreadPool(2);
818 >        try (PoolCleaner cleaner = cleaner(executor)) {
819 >            executor.execute(new CheckedRunnable() {
820 >                public void realRun() throws InterruptedException {
821 >                    assertNull(q.poll());
822 >                    threadsStarted.await();
823 >                    assertSame(one, q.poll(LONG_DELAY_MS, MILLISECONDS));
824 >                    checkEmpty(q);
825 >                }});
826 >
827 >            executor.execute(new CheckedRunnable() {
828 >                public void realRun() throws InterruptedException {
829 >                    threadsStarted.await();
830 >                    q.put(one);
831 >                }});
832 >        }
833      }
834  
835      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines