[cvs] / jsr166 / src / test / tck / AbstractExecutorServiceTest.java Repository:
ViewVC logotype

Diff of /jsr166/src/test/tck/AbstractExecutorServiceTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.37, Sat Apr 25 04:55:30 2015 UTC revision 1.38, Mon Sep 14 03:14:43 2015 UTC
# Line 16  Line 16 
16  import java.util.concurrent.AbstractExecutorService;  import java.util.concurrent.AbstractExecutorService;
17  import java.util.concurrent.ArrayBlockingQueue;  import java.util.concurrent.ArrayBlockingQueue;
18  import java.util.concurrent.Callable;  import java.util.concurrent.Callable;
19    import java.util.concurrent.CancellationException;
20  import java.util.concurrent.CountDownLatch;  import java.util.concurrent.CountDownLatch;
21  import java.util.concurrent.ExecutionException;  import java.util.concurrent.ExecutionException;
22  import java.util.concurrent.Executors;  import java.util.concurrent.Executors;
# Line 587  Line 588 
588              l.add(new StringTask());              l.add(new StringTask());
589              l.add(new StringTask());              l.add(new StringTask());
590              List<Future<String>> futures =              List<Future<String>> futures =
591                  e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);                  e.invokeAll(l, LONG_DELAY_MS, MILLISECONDS);
592              assertEquals(2, futures.size());              assertEquals(2, futures.size());
593              for (Future<String> future : futures)              for (Future<String> future : futures)
594                  assertSame(TEST_STRING, future.get());                  assertSame(TEST_STRING, future.get());
# Line 599  Line 600 
600      /**      /**
601       * timed invokeAll cancels tasks not completed by timeout       * timed invokeAll cancels tasks not completed by timeout
602       */       */
603      public void testTimedInvokeAll6() throws InterruptedException {      public void testTimedInvokeAll6() throws Exception {
604          ExecutorService e = new DirectExecutorService();          ExecutorService e = new DirectExecutorService();
605          try {          try {
606              List<Callable<String>> l = new ArrayList<Callable<String>>();              long timeout = timeoutMillis();
607              l.add(new StringTask());              List<Callable<String>> tasks = new ArrayList<>();
608              l.add(Executors.callable(possiblyInterruptedRunnable(2 * SHORT_DELAY_MS), TEST_STRING));              tasks.add(new StringTask("0"));
609              l.add(new StringTask());              tasks.add(Executors.callable(possiblyInterruptedRunnable(timeout),
610                                             TEST_STRING));
611                tasks.add(new StringTask("2"));
612                long startTime = System.nanoTime();
613              List<Future<String>> futures =              List<Future<String>> futures =
614                  e.invokeAll(l, SHORT_DELAY_MS, MILLISECONDS);                  e.invokeAll(tasks, timeout, MILLISECONDS);
615              assertEquals(l.size(), futures.size());              assertEquals(tasks.size(), futures.size());
616                assertTrue(millisElapsedSince(startTime) >= timeout);
617              for (Future future : futures)              for (Future future : futures)
618                  assertTrue(future.isDone());                  assertTrue(future.isDone());
619              assertFalse(futures.get(0).isCancelled());              assertEquals("0", futures.get(0).get());
620              assertFalse(futures.get(1).isCancelled());              assertEquals(TEST_STRING, futures.get(1).get());
621              assertTrue(futures.get(2).isCancelled());              assertTrue(futures.get(2).isCancelled());
622          } finally {          } finally {
623              joinPool(e);              joinPool(e);

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.38

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8