Package java.util.concurrent

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


     */
    @Test
    public void testFireUntilHaltWithAccumulateAndExpires() throws Exception {
        // thread for firing until halt
        final ExecutorService executor = Executors.newSingleThreadExecutor();
        final Future sessionFuture = executor.submit(new Runnable() {

            public void run() {
                statefulSession.fireUntilHalt();
            }
        });
View Full Code Here


            part = 1;
        }
        for (int i = 0; i < A.size(); i += part) {
            System.err.println(i);
            Callable<int[][]> worker = new LineMultiplier(A, B, i, i+part);
            Future<int[][]> submit = executor.submit(worker);
            list.add(submit);
        }

        // now retrieve the result
        int start = 0;
View Full Code Here

                        }
                        return count;
                    }
                });
            taskList.add(task);
            executor.submit(task);
        }

        executor.shutdown();
        if (!executor.awaitTermination(10,
            TimeUnit.MINUTES)) {
View Full Code Here

//    void call(int i) {}

    @Test
    public void test() {
        ExecutorService es = Executors.newCachedThreadPool();
        es.submit(this::call);
    }
}
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

    ExecutorService executor = Executors.newFixedThreadPool(threads);
    for(final Algorithm algorithm : algorithms){
      for(final BenchmarkInstance p : benchmarkInstances){
        for(int run=0;run<runs;run++){
          final int r = run;
          executor.submit(new Runnable(){

            @Override
            public void run() {
              runAlgorithm(p, algorithm, r+1);
            }
View Full Code Here

    Guice.createInjector(new AbstractModule() {
      protected void configure() {
        requestInjection(new Object() {
          @Inject void initialize(final Injector injector)
              throws ExecutionException, InterruptedException {
            Future<JustInTime> future = executorService.submit(new Callable<JustInTime>() {
              public JustInTime call() throws Exception {
                return injector.getInstance(JustInTime.class);
              }
            });
            got.set(future.get());
View Full Code Here

            final CountDownLatch latch1 = new CountDownLatch(NUM_THREADS);
            final CountDownLatch latch0 = new CountDownLatch(1);

            for(int i = 0; i < NUM_THREADS; i++) {
                final int threadId = i;
                executorService.submit(new Runnable() {

                    public void run() {
                        try {
                            latch0.await();
                            for(int j = 0; j < NUM_OPS; j++) {
View Full Code Here

            final ConcurrentLinkedQueue<Double> observedEventRate = new ConcurrentLinkedQueue<Double>();
            final ConcurrentLinkedQueue<Double> observedEventValueAvg = new ConcurrentLinkedQueue<Double>();
            final int NUM_INTERVALS = 30;
            final CountDownLatch latch2 = new CountDownLatch(NUM_THREADS);
            for(int i = 0; i < NUM_THREADS; i++) {
                executorService.submit(new Runnable() {

                    public void run() {
                        try {
                            for(int interval = 0; interval < NUM_INTERVALS; interval++) {
                                long startTimeMs = System.currentTimeMillis();
View Full Code Here

    protected void shutDown() throws Exception {
        LOG.debug("Stopping BufferSynchronizerService");
        if (indexerAvailable && cluster.isConnectedAndHealthy()) {
            final ExecutorService executorService = new InstrumentedExecutorService(Executors.newFixedThreadPool(2), metricRegistry);

            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    bufferSynchronizer.waitForEmptyBuffers(configuration.getShutdownTimeout(), TimeUnit.MILLISECONDS);
                }
            });
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.