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

Comparing jsr166/src/test/tck/ThreadPoolExecutorSubclassTest.java (file contents):
Revision 1.62 by jsr166, Sun Oct 4 02:04:56 2015 UTC vs.
Revision 1.67 by jsr166, Sun Oct 4 02:24:49 2015 UTC

# Line 252 | Line 252 | public class ThreadPoolExecutorSubclassT
252              new CustomTPE(2, 2,
253                            LONG_DELAY_MS, MILLISECONDS,
254                            new ArrayBlockingQueue<Runnable>(10));
255        final CountDownLatch threadStarted = new CountDownLatch(1);
256        final CountDownLatch done = new CountDownLatch(1);
255          try (PoolCleaner cleaner = cleaner(p)) {
256 +            final CountDownLatch threadStarted = new CountDownLatch(1);
257 +            final CountDownLatch done = new CountDownLatch(1);
258              assertEquals(0, p.getActiveCount());
259              p.execute(new CheckedRunnable() {
260                  public void realRun() throws InterruptedException {
# Line 262 | Line 262 | public class ThreadPoolExecutorSubclassT
262                      assertEquals(1, p.getActiveCount());
263                      done.await();
264                  }});
265 <            assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS));
265 >            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
266              assertEquals(1, p.getActiveCount());
267              done.countDown();
268          }
# Line 503 | Line 503 | public class ThreadPoolExecutorSubclassT
503       * otherwise set
504       */
505      public void testGetMaximumPoolSize() {
506 <        ThreadPoolExecutor p = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
507 <        assertEquals(2, p.getMaximumPoolSize());
508 <        joinPool(p);
506 >        final ThreadPoolExecutor p =
507 >            new CustomTPE(2, 3,
508 >                          LONG_DELAY_MS, MILLISECONDS,
509 >                          new ArrayBlockingQueue<Runnable>(10));
510 >        try (PoolCleaner cleaner = cleaner(p)) {
511 >            assertEquals(3, p.getMaximumPoolSize());
512 >            p.setMaximumPoolSize(5);
513 >            assertEquals(5, p.getMaximumPoolSize());
514 >            p.setMaximumPoolSize(4);
515 >            assertEquals(4, p.getMaximumPoolSize());
516 >        }
517      }
518  
519      /**
# Line 517 | Line 525 | public class ThreadPoolExecutorSubclassT
525              new CustomTPE(1, 1,
526                            LONG_DELAY_MS, MILLISECONDS,
527                            new ArrayBlockingQueue<Runnable>(10));
528 <        final CountDownLatch threadStarted = new CountDownLatch(1);
529 <        final CountDownLatch done = new CountDownLatch(1);
530 <        try {
528 >        try (PoolCleaner cleaner = cleaner(p)) {
529 >            final CountDownLatch threadStarted = new CountDownLatch(1);
530 >            final CountDownLatch done = new CountDownLatch(1);
531              assertEquals(0, p.getPoolSize());
532              p.execute(new CheckedRunnable() {
533                  public void realRun() throws InterruptedException {
# Line 527 | Line 535 | public class ThreadPoolExecutorSubclassT
535                      assertEquals(1, p.getPoolSize());
536                      done.await();
537                  }});
538 <            assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS));
538 >            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
539              assertEquals(1, p.getPoolSize());
540 <        } finally {
533 <            done.countDown();
534 <            joinPool(p);
540 >            done.countDown();   // release pool
541          }
542      }
543  
# Line 543 | Line 549 | public class ThreadPoolExecutorSubclassT
549              new CustomTPE(1, 1,
550                            LONG_DELAY_MS, MILLISECONDS,
551                            new ArrayBlockingQueue<Runnable>(10));
552 <        final CountDownLatch threadStarted = new CountDownLatch(1);
553 <        final CountDownLatch done = new CountDownLatch(1);
554 <        try {
552 >        try (PoolCleaner cleaner = cleaner(p)) {
553 >            final CountDownLatch threadStarted = new CountDownLatch(1);
554 >            final CountDownLatch done = new CountDownLatch(1);
555              assertEquals(0, p.getTaskCount());
556              p.execute(new CheckedRunnable() {
557                  public void realRun() throws InterruptedException {
# Line 553 | Line 559 | public class ThreadPoolExecutorSubclassT
559                      assertEquals(1, p.getTaskCount());
560                      done.await();
561                  }});
562 <            assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS));
562 >            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
563              assertEquals(1, p.getTaskCount());
558        } finally {
564              done.countDown();
560            joinPool(p);
565          }
566      }
567  
# Line 591 | Line 595 | public class ThreadPoolExecutorSubclassT
595                      threadStarted.countDown();
596                      done.await();
597                  }});
598 <            assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS));
598 >            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
599              assertFalse(p.isTerminating());
600              done.countDown();
601          } finally {
# Line 620 | Line 624 | public class ThreadPoolExecutorSubclassT
624                      threadStarted.countDown();
625                      done.await();
626                  }});
627 <            assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS));
627 >            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
628              assertFalse(p.isTerminating());
629              done.countDown();
630          } finally {
# Line 655 | Line 659 | public class ThreadPoolExecutorSubclassT
659                  tasks[i] = new FutureTask(task);
660                  p.execute(tasks[i]);
661              }
662 <            assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS));
662 >            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
663              assertSame(q, p.getQueue());
664              assertFalse(q.contains(tasks[0]));
665              assertTrue(q.contains(tasks[tasks.length - 1]));
# Line 687 | Line 691 | public class ThreadPoolExecutorSubclassT
691                          }};
692                  p.execute(tasks[i]);
693              }
694 <            assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS));
694 >            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
695              assertFalse(p.remove(tasks[0]));
696              assertTrue(q.contains(tasks[4]));
697              assertTrue(q.contains(tasks[3]));
# Line 726 | Line 730 | public class ThreadPoolExecutorSubclassT
730                  tasks[i] = new FutureTask(task);
731                  p.execute(tasks[i]);
732              }
733 <            assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS));
733 >            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
734              assertEquals(tasks.length, p.getTaskCount());
735              assertEquals(tasks.length - 1, q.size());
736              assertEquals(1L, p.getActiveCount());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines