Package java.util.concurrent

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


    Collection<Future<?>> futures = new ArrayList<Future<?>>(NUM_THREADS);
    Callable<?> loadTask = new LoadWorker(recommender);

    long start = System.currentTimeMillis();
    for (int i = 0; i < NUM_THREADS; i++) {
      futures.add(executor.submit(loadTask));
    }
    for (Future<?> future : futures) {
      future.get();
    }
    long end = System.currentTimeMillis();
View Full Code Here


    final GroupCommit commit = new GroupCommit();
    ExecutorService newFixedThreadPool = Executors.newFixedThreadPool(400);
    for (int i = 0; i < 2400; i++)
    {
      Runnable runnable = new MyClass(accessor, commit, i);
      newFixedThreadPool.submit(runnable);
    }
    Thread.sleep(10000);
    System.out.println(accessor.get("test", null, 0));
    System.out.println(accessor.get("test", null, 0).getSimpleFields().size());
  }
View Full Code Here

  // TODO: remove this
  public static void main(String[] args) throws Exception
  {
    ExecutorService pool = Executors.newFixedThreadPool(DEFAULT_PARALLEL_TASKS);
    Future<HelixTaskResult> future;
    future = pool.submit(new Callable<HelixTaskResult>()
    {

      @Override
      public HelixTaskResult call() throws Exception
      {
View Full Code Here

        System.out.println("CMTaskExecutor.main(...).new Callable() {...}.call()");
        return null;
      }

    });
    future = pool.submit(new HelixTask(null, null, null, null));
    Thread.currentThread().join();
    System.out.println(future.isDone());
  }
}
View Full Code Here

        final Set<PutToken> tokens = Collections.synchronizedSet(new HashSet<PutToken>());
        Set<Future<?>> results = new HashSet<Future<?>>();

        ExecutorService executorService = Executors.newFixedThreadPool(100);
        for (int i = 0; i < 100; i++) {
            results.add(executorService.submit(new Callable<Void>() {
                @Override
                public Void call() throws Exception {
                    for (int j = 0; j < 10000; j++) {
                        assertTrue(tokens.add(new PutTokenImpl()));
                    }
View Full Code Here

        // run workers concurrently
        ExecutorService executor = Executors.newFixedThreadPool(NB_THREADS);
        List<Future<String>> fs = new LinkedList<Future<String>>();
        for (Callable<String> c : cs) {
            fs.add(executor.submit(c));
        }
        executor.shutdown();
        executor.awaitTermination(10, TimeUnit.SECONDS);

        // get all results in order to verify if any of the threads has thrown
View Full Code Here

        final ExecutorService service = Executors.newCachedThreadPool();
        final Runnable[] tasks = solver.createParallelTasks(3, 5000);
        final List<Future<?>> execOutput = new ArrayList<Future<?>>();
        // Run tasks.
        for (Runnable r : tasks) {
            execOutput.add(service.submit(r));
        }
        // Wait for completion (ignoring return value).
        try {
            for (Future<?> f : execOutput) {
                f.get();
View Full Code Here

        // Finally, fill the pool and start it
        if (!options.get("BackgroundStartup", false) && min > 0)  {
            ExecutorService es = Executors.newFixedThreadPool(min);
            for (int i = 0; i < min; i++) {
                es.submit(new InstanceCreatorRunnable(maxAge, i, min, maxAgeOffset, data, supplier));
            }
            es.shutdown();
            try {
                es.awaitTermination(5, TimeUnit.MINUTES);
            } catch (InterruptedException e) {
View Full Code Here

  @Override
  public Future<?> start() {
    ExecutorService executor = Executors.newFixedThreadPool( 1, "batch coordinator" );
    try {
      return executor.submit( createCoordinator() );
    }
    finally {
      executor.shutdown();
    }
  }
View Full Code Here

            fail("did not get the expected IOException from the 2nd call");
          }
          fail("did not get the expected IOException from the 1st call");
        }
      };
      Future<?> result = executor.submit(runnable);
      try {
        result.get(2000, TimeUnit.MILLISECONDS);
      } catch (TimeoutException te) {
        // it is ok, expected.
      }
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.