Package java.util.concurrent

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


                    }
                });
            }

            final ExecutorService executorService = Executors.newFixedThreadPool(10);
            final List<Future<String>> results = executorService.invokeAll(callables);
            final Set<String> replies = new HashSet<String>();
            for (Future<String> future : results) {
                // wait at most 60 sec to not hang test
                String reply = future.get(60, TimeUnit.SECONDS);
                assertTrue(reply.startsWith("Bye "));
View Full Code Here


            tasks.add(callable);
        }

        List<Future<ScheduleExecutionResult>> resultFutures;
        try {
            resultFutures = executorService.invokeAll(tasks);

            executorService.shutdown();

            boolean terminated = executorService.awaitTermination(POOL_SHUTDOWN_WAIT_MS, TimeUnit.MILLISECONDS);
            if (!terminated) {
View Full Code Here

        return i;
      }
    };

    List<Future<Integer>> futures =
        executor.invokeAll(Collections.nCopies(10, incrementTask));

    for (int i = 0; i < 10; i++) {
      Future<Integer> future = futures.get(i);
      assertTrue("Task should have been run before being returned", future.isDone());
      assertEquals(i, future.get().intValue());
View Full Code Here

            throw new MojoFailureException(e.getMessage(), e);
        }

        ExecutorService executor = Executors.newFixedThreadPool(2);
        try {
            List<Future<Object>> futures = executor.invokeAll(processFilesTasks);
            for (Future<Object> future : futures) {
                try {
                    future.get();
                } catch (ExecutionException e) {
                    throw new MojoExecutionException(e.getMessage(), e);
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

        mock.expectedBodiesReceived(total);
        mock.expectedHeaderReceived("total", total);
        mock.expectedPropertyReceived(Exchange.AGGREGATED_SIZE, size);

        // submit all tasks
        service.invokeAll(tasks);

        assertMockEndpointsSatisfied();

        assertEquals(100, COUNTER.get());
        // Need to shutdown the threadpool
View Full Code Here

        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(5);

        // submit all tasks
        service.invokeAll(tasks);

        assertMockEndpointsSatisfied();
        service.shutdownNow();
    }
View Full Code Here

                    }
                });
        }

        final ExecutorService exec = Executors.newFixedThreadPool(numThreads);
        final List<Future<Double>> results = exec.invokeAll(tasks);

        final double[] values = new double[numGenerators];
        for (int i = 0; i < numGenerators; i++) {
            values[i] = results.get(i).get();
        }
View Full Code Here

                        service.returnLock(lock);
                    }
                }
            });
        }
        executorService.invokeAll(tasks);
    }
}
View Full Code Here

    List<Callable<Object>> taskList = new ArrayList<Callable<Object>>(nMod);
    for (int nSlice = 1; nSlice <= nMod; nSlice++) {
      taskList.add(new SliceEvaluator(instanceIDMap, nMod, nSlice,
          evalTest));
    }
    svc.invokeAll(taskList);
    svc.shutdown();
    svc.awaitTermination(60 * 4, TimeUnit.MINUTES);
  }

  public void evaluateKernelOnCorpus(final Map<Long, Node> instanceIDMap,
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.