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.83 by jsr166, Mon Oct 5 20:45:41 2015 UTC vs.
Revision 1.84 by jsr166, Mon Oct 5 21:42:48 2015 UTC

# Line 545 | Line 545 | public class ThreadPoolExecutorSubclassT
545       * getTaskCount increases, but doesn't overestimate, when tasks submitted
546       */
547      public void testGetTaskCount() throws InterruptedException {
548 +        final int TASKS = 3;
549 +        final CountDownLatch done = new CountDownLatch(1);
550          final ThreadPoolExecutor p =
551              new CustomTPE(1, 1,
552                            LONG_DELAY_MS, MILLISECONDS,
553                            new ArrayBlockingQueue<Runnable>(10));
554 <        try (PoolCleaner cleaner = cleaner(p)) {
554 >        try (PoolCleaner cleaner = cleaner(p, done)) {
555              final CountDownLatch threadStarted = new CountDownLatch(1);
554            final CountDownLatch done = new CountDownLatch(1);
556              assertEquals(0, p.getTaskCount());
557 +            assertEquals(0, p.getCompletedTaskCount());
558              p.execute(new CheckedRunnable() {
559                  public void realRun() throws InterruptedException {
560                      threadStarted.countDown();
559                    assertEquals(1, p.getTaskCount());
561                      done.await();
562                  }});
563 <            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
563 >            assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS));
564              assertEquals(1, p.getTaskCount());
565 <            done.countDown();
565 >            assertEquals(0, p.getCompletedTaskCount());
566 >            for (int i = 0; i < TASKS; i++) {
567 >                assertEquals(1 + i, p.getTaskCount());
568 >                p.execute(new CheckedRunnable() {
569 >                    public void realRun() throws InterruptedException {
570 >                        threadStarted.countDown();
571 >                        assertEquals(1 + TASKS, p.getTaskCount());
572 >                        done.await();
573 >                    }});
574 >            }
575 >            assertEquals(1 + TASKS, p.getTaskCount());
576 >            assertEquals(0, p.getCompletedTaskCount());
577          }
578 +        assertEquals(1 + TASKS, p.getTaskCount());
579 +        assertEquals(1 + TASKS, p.getCompletedTaskCount());
580      }
581  
582      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines