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.92 by jsr166, Tue Oct 6 05:56:01 2015 UTC vs.
Revision 1.94 by jsr166, Thu Oct 8 03:03:36 2015 UTC

# Line 1725 | Line 1725 | public class ThreadPoolExecutorSubclassT
1725                            LONG_DELAY_MS, MILLISECONDS,
1726                            new ArrayBlockingQueue<Runnable>(10));
1727          try (PoolCleaner cleaner = cleaner(e)) {
1728 +            long startTime = System.nanoTime();
1729              List<Callable<String>> l = new ArrayList<Callable<String>>();
1730              l.add(new NPETask());
1731              try {
1732 <                e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1732 >                e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS);
1733                  shouldThrow();
1734              } catch (ExecutionException success) {
1735                  assertTrue(success.getCause() instanceof NullPointerException);
1736              }
1737 +            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1738          }
1739      }
1740  
# Line 1868 | Line 1870 | public class ThreadPoolExecutorSubclassT
1870       * timed invokeAll(c) cancels tasks not completed by timeout
1871       */
1872      public void testTimedInvokeAll6() throws Exception {
1873 <        final ExecutorService e =
1874 <            new CustomTPE(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 CustomTPE(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