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

Comparing jsr166/src/test/tck/SynchronousQueueTest.java (file contents):
Revision 1.48 by jsr166, Wed Jun 10 07:10:50 2015 UTC vs.
Revision 1.49 by jsr166, Sun Oct 4 18:28:51 2015 UTC

# Line 469 | Line 469 | public class SynchronousQueueTest extend
469      public void testOfferInExecutor_fair() { testOfferInExecutor(true); }
470      public void testOfferInExecutor(boolean fair) {
471          final SynchronousQueue q = new SynchronousQueue(fair);
472        ExecutorService executor = Executors.newFixedThreadPool(2);
472          final CheckedBarrier threadsStarted = new CheckedBarrier(2);
473 +        final ExecutorService executor = Executors.newFixedThreadPool(2);
474 +        try (PoolCleaner cleaner = cleaner(executor)) {
475  
476 <        executor.execute(new CheckedRunnable() {
477 <            public void realRun() throws InterruptedException {
478 <                assertFalse(q.offer(one));
479 <                threadsStarted.await();
480 <                assertTrue(q.offer(one, LONG_DELAY_MS, MILLISECONDS));
481 <                assertEquals(0, q.remainingCapacity());
482 <            }});
483 <
484 <        executor.execute(new CheckedRunnable() {
485 <            public void realRun() throws InterruptedException {
486 <                threadsStarted.await();
487 <                assertSame(one, q.take());
488 <            }});
489 <
489 <        joinPool(executor);
476 >            executor.execute(new CheckedRunnable() {
477 >                public void realRun() throws InterruptedException {
478 >                    assertFalse(q.offer(one));
479 >                    threadsStarted.await();
480 >                    assertTrue(q.offer(one, LONG_DELAY_MS, MILLISECONDS));
481 >                    assertEquals(0, q.remainingCapacity());
482 >                }});
483 >
484 >            executor.execute(new CheckedRunnable() {
485 >                public void realRun() throws InterruptedException {
486 >                    threadsStarted.await();
487 >                    assertSame(one, q.take());
488 >                }});
489 >        }
490      }
491  
492      /**
# Line 497 | Line 497 | public class SynchronousQueueTest extend
497      public void testPollInExecutor(boolean fair) {
498          final SynchronousQueue q = new SynchronousQueue(fair);
499          final CheckedBarrier threadsStarted = new CheckedBarrier(2);
500 <        ExecutorService executor = Executors.newFixedThreadPool(2);
501 <        executor.execute(new CheckedRunnable() {
502 <            public void realRun() throws InterruptedException {
503 <                assertNull(q.poll());
504 <                threadsStarted.await();
505 <                assertSame(one, q.poll(LONG_DELAY_MS, MILLISECONDS));
506 <                assertTrue(q.isEmpty());
507 <            }});
508 <
509 <        executor.execute(new CheckedRunnable() {
510 <            public void realRun() throws InterruptedException {
511 <                threadsStarted.await();
512 <                q.put(one);
513 <            }});
514 <
515 <        joinPool(executor);
500 >        final ExecutorService executor = Executors.newFixedThreadPool(2);
501 >        try (PoolCleaner cleaner = cleaner(executor)) {
502 >            executor.execute(new CheckedRunnable() {
503 >                public void realRun() throws InterruptedException {
504 >                    assertNull(q.poll());
505 >                    threadsStarted.await();
506 >                    assertSame(one, q.poll(LONG_DELAY_MS, MILLISECONDS));
507 >                    assertTrue(q.isEmpty());
508 >                }});
509 >
510 >            executor.execute(new CheckedRunnable() {
511 >                public void realRun() throws InterruptedException {
512 >                    threadsStarted.await();
513 >                    q.put(one);
514 >                }});
515 >        }
516      }
517  
518      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines