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

Comparing jsr166/src/test/tck/AbstractExecutorServiceTest.java (file contents):
Revision 1.40 by jsr166, Sun Oct 4 18:18:48 2015 UTC vs.
Revision 1.43 by jsr166, Thu Oct 8 03:03:36 2015 UTC

# Line 194 | Line 194 | public class AbstractExecutorServiceTest
194          final CountDownLatch quittingTime = new CountDownLatch(1);
195          final Callable<Void> awaiter = new CheckedCallable<Void>() {
196              public Void realCall() throws InterruptedException {
197 <                quittingTime.await();
197 >                assertTrue(quittingTime.await(2*LONG_DELAY_MS, MILLISECONDS));
198                  return null;
199              }};
200          final ExecutorService p
201              = new ThreadPoolExecutor(1,1,60, TimeUnit.SECONDS,
202                                       new ArrayBlockingQueue<Runnable>(10));
203 <        try (PoolCleaner cleaner = cleaner(p)) {
204 <            Thread t = new Thread(new CheckedInterruptedRunnable() {
203 >        try (PoolCleaner cleaner = cleaner(p, quittingTime)) {
204 >            Thread t = newStartedThread(new CheckedInterruptedRunnable() {
205                  public void realRun() throws Exception {
206                      Future<Void> future = p.submit(awaiter);
207                      submitted.countDown();
208                      future.get();
209                  }});
210 <            t.start();
211 <            submitted.await();
210 >
211 >            await(submitted);
212              t.interrupt();
213 <            t.join();
214 <            quittingTime.countDown();
213 >            awaitTermination(t);
214          }
215      }
216  
# Line 450 | Line 449 | public class AbstractExecutorServiceTest
449      public void testTimedInvokeAny4() throws Exception {
450          final ExecutorService e = new DirectExecutorService();
451          try (PoolCleaner cleaner = cleaner(e)) {
452 +            long startTime = System.nanoTime();
453              List<Callable<String>> l = new ArrayList<Callable<String>>();
454              l.add(new NPETask());
455              try {
456 <                e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
456 >                e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS);
457                  shouldThrow();
458              } catch (ExecutionException success) {
459                  assertTrue(success.getCause() instanceof NullPointerException);
460              }
461 +            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
462          }
463      }
464  
# Line 539 | Line 540 | public class AbstractExecutorServiceTest
540              List<Callable<String>> l = new ArrayList<Callable<String>>();
541              l.add(new NPETask());
542              List<Future<String>> futures =
543 <                e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
543 >                e.invokeAll(l, LONG_DELAY_MS, MILLISECONDS);
544              assertEquals(1, futures.size());
545              try {
546                  futures.get(0).get();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines