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.109 by jsr166, Tue Oct 6 06:11:32 2015 UTC vs.
Revision 1.110 by jsr166, Tue Oct 6 16:39:06 2015 UTC

# Line 1870 | Line 1870 | public class ThreadPoolExecutorTest exte
1870       * timed invokeAll(c) cancels tasks not completed by timeout
1871       */
1872      public void testTimedInvokeAll6() throws Exception {
1873 <        final ExecutorService e =
1874 <            new ThreadPoolExecutor(2, 2,
1875 <                                   LONG_DELAY_MS, MILLISECONDS,
1876 <                                   new ArrayBlockingQueue<Runnable>(10));
1877 <        try (PoolCleaner cleaner = cleaner(e)) {
1878 <            for (long timeout = timeoutMillis();;) {
1873 >        for (long timeout = timeoutMillis();;) {
1874 >            final CountDownLatch done = new CountDownLatch(1);
1875 >            final Callable<String> waiter = new CheckedCallable<String>() {
1876 >                public String realCall() {
1877 >                    try { done.await(LONG_DELAY_MS, MILLISECONDS); }
1878 >                    catch (InterruptedException ok) {}
1879 >                    return "1"; }};
1880 >            final ExecutorService p =
1881 >                new ThreadPoolExecutor(2, 2,
1882 >                                       LONG_DELAY_MS, MILLISECONDS,
1883 >                                       new ArrayBlockingQueue<Runnable>(10));
1884 >            try (PoolCleaner cleaner = cleaner(p, done)) {
1885                  List<Callable<String>> tasks = new ArrayList<>();
1886                  tasks.add(new StringTask("0"));
1887 <                tasks.add(Executors.callable(new LongPossiblyInterruptedRunnable(), TEST_STRING));
1887 >                tasks.add(waiter);
1888                  tasks.add(new StringTask("2"));
1889                  long startTime = System.nanoTime();
1890                  List<Future<String>> futures =
1891 <                    e.invokeAll(tasks, timeout, MILLISECONDS);
1891 >                    p.invokeAll(tasks, timeout, MILLISECONDS);
1892                  assertEquals(tasks.size(), futures.size());
1893                  assertTrue(millisElapsedSince(startTime) >= timeout);
1894                  for (Future future : futures)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines