Package java.util.concurrent

Examples of java.util.concurrent.ExecutorService.invokeAll()


     */
    public List invokeAll(Collection tasks)
            throws InterruptedException {
        ExecutorService service = delegate.get();
        if (service != null) {
            return service.invokeAll(taskManager.trackTasks(tasks));
        }
        throw new RejectedExecutionException(
                "Execution service is terminated. No more tasks can be executed.");
    }

View Full Code Here


            TestRunner without = new TestRunner(null,null,datasource.getPoolProperties().getUsername(),datasource.getPoolProperties().getPassword());
            runners[i] = allowUsernameChange?with:without;
            runners[i+withuser] = without;
        }
        ExecutorService svc = Executors.newFixedThreadPool(withuser+withoutuser);
        List<Future<TestResult>> results =  svc.invokeAll(Arrays.asList(runners));
        int failures = 0;
        int total = 0;
        for (int i=0; i<withuser; i++) {
            failures += results.get(i).get().failures;
            total+=results.get(i).get().iterations;
View Full Code Here

            }
        };
        Collection<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>();
        tasks.add(consumer);
        tasks.add(producer);
        final List<Future<Integer>> futures = threadPool.invokeAll(tasks);
        for (Future<Integer> future : futures) {
            Assert.assertEquals(REPEAT, future.get().intValue());
        }
    }
}
View Full Code Here

            }
        };
        Collection<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>();
        tasks.add(consumer);
        tasks.add(consumer);
        final List<Future<Integer>> futures = threadPool.invokeAll(tasks);
        for (Future<Integer> future : futures) {
            future.get();
        }
    }
}
View Full Code Here

    // Use a thread pool to execute the Callables in parallel
    List<Future<HdfsBlocksMetadata>> futures =
        new ArrayList<Future<HdfsBlocksMetadata>>();
    ExecutorService executor = new ScheduledThreadPoolExecutor(poolsize);
    try {
      futures = executor.invokeAll(callables, timeout, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
      // Swallow the exception here, because we can return partial results
    }
    executor.shutdown();
   
View Full Code Here

                        }
                    }
                });
            }
            try {
                List<Future<Boolean>> futures = service.invokeAll(tasks);
                for(Future<Boolean> future: futures) {
                    assertTrue(future.get());
                }
            } catch(Exception e) {
                fail("Unexpected exception - " + e.getMessage());
View Full Code Here

        }
      });
    }

    try {
      es.invokeAll(tasks);
      es.shutdown();
    } catch (InterruptedException e) {
      throw new RuntimeException("Impossible error");
    }
View Full Code Here

      callables.add(callable);
    }

    List<Future<IStatus>> futures = null;
    try {
      futures = threadPool.invokeAll(callables);
      threadPool.shutdownNow();
      long endTime = System.currentTimeMillis();
      long timeInSec = (endTime - startTime) / 1000;
      long sec = timeInSec % 60;
      long min = (timeInSec - sec) / 60;
View Full Code Here

   
    ExecutorService executor = Executors.newFixedThreadPool(count);
   
    try
    {
      List<Future<SimpleObject>> futures = executor.invokeAll(tasks);
     
      for (Future<SimpleObject> future: futures)
      {
        ExecutionException exception = null;
       
View Full Code Here

   
    ExecutorService executor = Executors.newFixedThreadPool(count);
   
    try
    {
      List<Future<SimpleObject>> futures = executor.invokeAll(tasks);
     
      int fail = 0;
     
      // Only 1 of these will succeed, the rest will timeout.
      for (Future<SimpleObject> future: futures)
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.