Package java.util.concurrent

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


            }

            ExecutorService executor = Executors.newFixedThreadPool(numThreads);
            long start = System.currentTimeMillis();

            List<Future<Long>> results = executor.invokeAll(clients,
                                                            10, TimeUnit.MINUTES);
            long end = System.currentTimeMillis();
            long count = 0;
            for (Future<Long> r : results) {
                if (!r.isDone()) {
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");
        MockEndpoint mock2 = getMockEndpoint2("mock:result");

        // submit all tasks
        service.invokeAll(tasks);
        service.shutdown();
        service.awaitTermination(10, TimeUnit.SECONDS);

        int contextCount = mock.getReceivedCounter();
        int context2Count = mock2.getReceivedCounter();
View Full Code Here

                    }
                });
            }

            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

        for (int i = 0; i < _noOfThreads; i++) {
            callables.add(new WebServiceInvoker(i));
        }

        ExecutorService executorService = Executors.newFixedThreadPool(DEFAULT_THREAD_COUNT);
        Collection<Future<String>> futures = executorService.invokeAll(callables);
        Assert.assertEquals(futures.size(), _noOfThreads);
        int i = 0;

        for (Future<String> future : futures) {
            response = future.get();
View Full Code Here

                public Boolean call() {
                    return threadPoolRejectionCommand().execute();
                }
            });
        }
        final Collection<Future<Boolean>> results = executorService.invokeAll(rejectCommands);
        boolean rejectionFound = false;
        for (final Future<Boolean> future : results) {
            if (future.get()) {
                rejectionFound = true;
            }
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

      Reader reader = new Reader(getDatabaseURL(server));
      workers.add(reader);
    }

    List<Future<Void>> futures = executor.invokeAll(workers);

    System.out.println("Threads started, waiting for the end");

    executor.shutdown();
    Assert.assertTrue(executor.awaitTermination(10, TimeUnit.MINUTES));
View Full Code Here

      Reader reader = new Reader(getDatabaseURL(server));
      workers.add(reader);
    }

    List<Future<Void>> futures = executor.invokeAll(workers);

    System.out.println("Threads started, waiting for the end");

    executor.shutdown();
    Assert.assertTrue(executor.awaitTermination(10, TimeUnit.MINUTES));
View Full Code Here

               List<Callable<CheckResult>> tasks = new ArrayList<Callable<CheckResult>>();
               for (int i = 0; i < checkThreads; ++i) {
                  Range range = Range.divideRange(numEntries, checkThreads, i);
                  tasks.add(new CheckRangeTask(range.getStart(), range.getEnd()));
               }
               for (Future<CheckResult> future : executor.invokeAll(tasks)) {
                  CheckResult value = future.get();
                  result.merge(value);
               }
               executor.shutdown();
            }
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.