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.102 by jsr166, Mon Oct 5 22:09:02 2015 UTC vs.
Revision 1.103 by jsr166, Mon Oct 5 22:19:00 2015 UTC

# Line 329 | Line 329 | public class ThreadPoolExecutorTest exte
329       */
330      public void testGetLargestPoolSize() throws InterruptedException {
331          final int THREADS = 3;
332 +        final CountDownLatch done = new CountDownLatch(1);
333          final ThreadPoolExecutor p =
334              new ThreadPoolExecutor(THREADS, THREADS,
335                                     LONG_DELAY_MS, MILLISECONDS,
336                                     new ArrayBlockingQueue<Runnable>(10));
337 <        try (PoolCleaner cleaner = cleaner(p)) {
337 <            final CountDownLatch threadsStarted = new CountDownLatch(THREADS);
338 <            final CountDownLatch done = new CountDownLatch(1);
337 >        try (PoolCleaner cleaner = cleaner(p, done)) {
338              assertEquals(0, p.getLargestPoolSize());
339 +            final CountDownLatch threadsStarted = new CountDownLatch(THREADS);
340              for (int i = 0; i < THREADS; i++)
341                  p.execute(new CheckedRunnable() {
342                      public void realRun() throws InterruptedException {
# Line 346 | Line 346 | public class ThreadPoolExecutorTest exte
346                      }});
347              assertTrue(threadsStarted.await(LONG_DELAY_MS, MILLISECONDS));
348              assertEquals(THREADS, p.getLargestPoolSize());
349            done.countDown();   // release pool
349          }
350          assertEquals(THREADS, p.getLargestPoolSize());
351      }
# Line 374 | Line 373 | public class ThreadPoolExecutorTest exte
373       * become active
374       */
375      public void testGetPoolSize() throws InterruptedException {
376 +        final CountDownLatch done = new CountDownLatch(1);
377          final ThreadPoolExecutor p =
378              new ThreadPoolExecutor(1, 1,
379                                     LONG_DELAY_MS, MILLISECONDS,
380                                     new ArrayBlockingQueue<Runnable>(10));
381 <        try (PoolCleaner cleaner = cleaner(p)) {
382 <            final CountDownLatch threadStarted = new CountDownLatch(1);
383 <            final CountDownLatch done = new CountDownLatch(1);
381 >        try (PoolCleaner cleaner = cleaner(p, done)) {
382              assertEquals(0, p.getPoolSize());
383 +            final CountDownLatch threadStarted = new CountDownLatch(1);
384              p.execute(new CheckedRunnable() {
385                  public void realRun() throws InterruptedException {
386                      threadStarted.countDown();
# Line 390 | Line 389 | public class ThreadPoolExecutorTest exte
389                  }});
390              assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS));
391              assertEquals(1, p.getPoolSize());
393            done.countDown();   // release pool
392          }
393      }
394  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines