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

Comparing jsr166/src/test/tck/ThreadPoolExecutorTest.java (file contents):
Revision 1.99 by jsr166, Mon Oct 5 20:45:41 2015 UTC vs.
Revision 1.100 by jsr166, Mon Oct 5 21:42:49 2015 UTC

# Line 398 | Line 398 | public class ThreadPoolExecutorTest exte
398       * getTaskCount increases, but doesn't overestimate, when tasks submitted
399       */
400      public void testGetTaskCount() throws InterruptedException {
401 +        final int TASKS = 3;
402 +        final CountDownLatch done = new CountDownLatch(1);
403          final ThreadPoolExecutor p =
404              new ThreadPoolExecutor(1, 1,
405                                     LONG_DELAY_MS, MILLISECONDS,
406                                     new ArrayBlockingQueue<Runnable>(10));
407 <        try (PoolCleaner cleaner = cleaner(p)) {
407 >        try (PoolCleaner cleaner = cleaner(p, done)) {
408              final CountDownLatch threadStarted = new CountDownLatch(1);
407            final CountDownLatch done = new CountDownLatch(1);
409              assertEquals(0, p.getTaskCount());
410 +            assertEquals(0, p.getCompletedTaskCount());
411              p.execute(new CheckedRunnable() {
412                  public void realRun() throws InterruptedException {
413                      threadStarted.countDown();
412                    assertEquals(1, p.getTaskCount());
414                      done.await();
415                  }});
416 <            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
416 >            assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS));
417              assertEquals(1, p.getTaskCount());
418 <            done.countDown();
418 >            assertEquals(0, p.getCompletedTaskCount());
419 >            for (int i = 0; i < TASKS; i++) {
420 >                assertEquals(1 + i, p.getTaskCount());
421 >                p.execute(new CheckedRunnable() {
422 >                    public void realRun() throws InterruptedException {
423 >                        threadStarted.countDown();
424 >                        assertEquals(1 + TASKS, p.getTaskCount());
425 >                        done.await();
426 >                    }});
427 >            }
428 >            assertEquals(1 + TASKS, p.getTaskCount());
429 >            assertEquals(0, p.getCompletedTaskCount());
430          }
431 +        assertEquals(1 + TASKS, p.getTaskCount());
432 +        assertEquals(1 + TASKS, p.getCompletedTaskCount());
433      }
434  
435      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines