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.114 by jsr166, Wed Jan 4 06:09:58 2017 UTC vs.
Revision 1.118 by jsr166, Mon May 29 19:15:03 2017 UTC

# Line 18 | Line 18 | import java.util.concurrent.Callable;
18   import java.util.concurrent.CancellationException;
19   import java.util.concurrent.CountDownLatch;
20   import java.util.concurrent.ExecutionException;
21 import java.util.concurrent.Executors;
21   import java.util.concurrent.ExecutorService;
22   import java.util.concurrent.Future;
23   import java.util.concurrent.FutureTask;
# Line 91 | Line 90 | public class ThreadPoolExecutorTest exte
90              final Runnable task = new CheckedRunnable() {
91                  public void realRun() { done.countDown(); }};
92              p.execute(task);
93 <            assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
93 >            await(done);
94          }
95      }
96  
# Line 185 | Line 184 | public class ThreadPoolExecutorTest exte
184                  public void realRun() throws InterruptedException {
185                      threadStarted.countDown();
186                      assertEquals(0, p.getCompletedTaskCount());
187 <                    threadProceed.await();
187 >                    await(threadProceed);
188                      threadDone.countDown();
189                  }});
190              await(threadStarted);
191              assertEquals(0, p.getCompletedTaskCount());
192              threadProceed.countDown();
193 <            threadDone.await();
193 >            await(threadDone);
194              long startTime = System.nanoTime();
195              while (p.getCompletedTaskCount() != 1) {
196                  if (millisElapsedSince(startTime) > LONG_DELAY_MS)
# Line 275 | Line 274 | public class ThreadPoolExecutorTest exte
274      }
275  
276      /**
277 +     * The default rejected execution handler is AbortPolicy.
278 +     */
279 +    public void testDefaultRejectedExecutionHandler() {
280 +        final ThreadPoolExecutor p =
281 +            new ThreadPoolExecutor(1, 2,
282 +                                   LONG_DELAY_MS, MILLISECONDS,
283 +                                   new ArrayBlockingQueue<Runnable>(10));
284 +        try (PoolCleaner cleaner = cleaner(p)) {
285 +            assertTrue(p.getRejectedExecutionHandler()
286 +                       instanceof ThreadPoolExecutor.AbortPolicy);
287 +        }
288 +    }
289 +
290 +    /**
291       * getRejectedExecutionHandler returns handler in constructor if not set
292       */
293      public void testGetRejectedExecutionHandler() {
# Line 457 | Line 470 | public class ThreadPoolExecutorTest exte
470              assertFalse(p.awaitTermination(Long.MIN_VALUE, MILLISECONDS));
471              assertFalse(p.awaitTermination(-1L, NANOSECONDS));
472              assertFalse(p.awaitTermination(-1L, MILLISECONDS));
473 <            assertFalse(p.awaitTermination(0L, NANOSECONDS));
474 <            assertFalse(p.awaitTermination(0L, MILLISECONDS));
473 >            assertFalse(p.awaitTermination(randomExpiredTimeout(),
474 >                                           randomTimeUnit()));
475              long timeoutNanos = 999999L;
476              long startTime = System.nanoTime();
477              assertFalse(p.awaitTermination(timeoutNanos, NANOSECONDS));
# Line 1112 | Line 1125 | public class ThreadPoolExecutorTest exte
1125                      await(done);
1126                  }};
1127              for (int i = 0; i < 2; ++i)
1128 <                p.submit(Executors.callable(task));
1128 >                p.execute(task);
1129              for (int i = 0; i < 2; ++i) {
1130                  try {
1131                      p.execute(task);
# Line 1928 | Line 1941 | public class ThreadPoolExecutorTest exte
1941                      public void realRun() {
1942                          done.countDown();
1943                      }});
1944 <            assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
1944 >            await(done);
1945          }
1946      }
1947  
# Line 2021 | Line 2034 | public class ThreadPoolExecutorTest exte
2034                  }
2035              }
2036              // enough time to run all tasks
2037 <            assertTrue(done.await(nTasks * SHORT_DELAY_MS, MILLISECONDS));
2037 >            await(done, nTasks * SHORT_DELAY_MS);
2038          }
2039      }
2040  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines