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.85 by jsr166, Mon Oct 5 21:54:33 2015 UTC vs.
Revision 1.87 by jsr166, Mon Oct 5 22:19:00 2015 UTC

# Line 262 | Line 262 | public class ThreadPoolExecutorSubclassT
262                      assertEquals(1, p.getActiveCount());
263                      done.await();
264                  }});
265 <            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
265 >            assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS));
266              assertEquals(1, p.getActiveCount());
267              done.countDown();
268          }
# Line 476 | Line 476 | public class ThreadPoolExecutorSubclassT
476       */
477      public void testGetLargestPoolSize() throws InterruptedException {
478          final int THREADS = 3;
479 +        final CountDownLatch done = new CountDownLatch(1);
480          final ThreadPoolExecutor p =
481              new CustomTPE(THREADS, THREADS,
482                            LONG_DELAY_MS, MILLISECONDS,
483                            new ArrayBlockingQueue<Runnable>(10));
484 <        try (PoolCleaner cleaner = cleaner(p)) {
484 <            final CountDownLatch threadsStarted = new CountDownLatch(THREADS);
485 <            final CountDownLatch done = new CountDownLatch(1);
484 >        try (PoolCleaner cleaner = cleaner(p, done)) {
485              assertEquals(0, p.getLargestPoolSize());
486 +            final CountDownLatch threadsStarted = new CountDownLatch(THREADS);
487              for (int i = 0; i < THREADS; i++)
488                  p.execute(new CheckedRunnable() {
489                      public void realRun() throws InterruptedException {
# Line 491 | Line 491 | public class ThreadPoolExecutorSubclassT
491                          done.await();
492                          assertEquals(THREADS, p.getLargestPoolSize());
493                      }});
494 <            assertTrue(threadsStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
494 >            assertTrue(threadsStarted.await(LONG_DELAY_MS, MILLISECONDS));
495              assertEquals(THREADS, p.getLargestPoolSize());
496            done.countDown();   // release pool
496          }
497          assertEquals(THREADS, p.getLargestPoolSize());
498      }
# Line 521 | Line 520 | public class ThreadPoolExecutorSubclassT
520       * become active
521       */
522      public void testGetPoolSize() throws InterruptedException {
523 +        final CountDownLatch done = new CountDownLatch(1);
524          final ThreadPoolExecutor p =
525              new CustomTPE(1, 1,
526                            LONG_DELAY_MS, MILLISECONDS,
527                            new ArrayBlockingQueue<Runnable>(10));
528 <        try (PoolCleaner cleaner = cleaner(p)) {
529 <            final CountDownLatch threadStarted = new CountDownLatch(1);
530 <            final CountDownLatch done = new CountDownLatch(1);
528 >        try (PoolCleaner cleaner = cleaner(p, done)) {
529              assertEquals(0, p.getPoolSize());
530 +            final CountDownLatch threadStarted = new CountDownLatch(1);
531              p.execute(new CheckedRunnable() {
532                  public void realRun() throws InterruptedException {
533                      threadStarted.countDown();
534                      assertEquals(1, p.getPoolSize());
535                      done.await();
536                  }});
537 <            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
537 >            assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS));
538              assertEquals(1, p.getPoolSize());
540            done.countDown();   // release pool
539          }
540      }
541  
# Line 612 | Line 610 | public class ThreadPoolExecutorSubclassT
610                      threadStarted.countDown();
611                      done.await();
612                  }});
613 <            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
613 >            assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS));
614              assertFalse(p.isTerminating());
615              done.countDown();
616              try { p.shutdown(); } catch (SecurityException ok) { return; }
# Line 640 | Line 638 | public class ThreadPoolExecutorSubclassT
638                      threadStarted.countDown();
639                      done.await();
640                  }});
641 <            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
641 >            assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS));
642              assertFalse(p.isTerminating());
643              done.countDown();
644              try { p.shutdown(); } catch (SecurityException ok) { return; }
# Line 674 | Line 672 | public class ThreadPoolExecutorSubclassT
672                  tasks[i] = new FutureTask(task);
673                  p.execute(tasks[i]);
674              }
675 <            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
675 >            assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS));
676              assertSame(q, p.getQueue());
677              assertFalse(q.contains(tasks[0]));
678              assertTrue(q.contains(tasks[tasks.length - 1]));
# Line 704 | Line 702 | public class ThreadPoolExecutorSubclassT
702                      }};
703                  p.execute(tasks[i]);
704              }
705 <            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
705 >            assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS));
706              assertFalse(p.remove(tasks[0]));
707              assertTrue(q.contains(tasks[4]));
708              assertTrue(q.contains(tasks[3]));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines