Package java.util.concurrent

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


   public static void stressTestDirectory(Directory dir, String testLabel) throws InterruptedException, IOException {
      SharedState state = new SharedState(DICTIONARY_SIZE);
      CacheTestSupport.initializeDirectory(dir);
      ExecutorService e = Executors.newFixedThreadPool(READER_THREADS + WRITER_THREADS);
      for (int i = 0; i < READER_THREADS; i++) {
         e.execute(new LuceneReaderThread(dir, state));
      }
      for (int i = 0; i < WRITER_THREADS; i++) {
         e.execute(new LuceneWriterThread(dir, state));
      }
      e.shutdown();
View Full Code Here


      ExecutorService e = Executors.newFixedThreadPool(READER_THREADS + WRITER_THREADS);
      for (int i = 0; i < READER_THREADS; i++) {
         e.execute(new LuceneReaderThread(dir, state));
      }
      for (int i = 0; i < WRITER_THREADS; i++) {
         e.execute(new LuceneWriterThread(dir, state));
      }
      e.shutdown();
      state.startWaitingThreads();
      Thread.sleep(DURATION_MS);
      long searchesCount = state.incrementIndexSearchesCount(0);
View Full Code Here

     * {@inheritDoc}
     */
    public void execute(Runnable command) {
        ExecutorService service = delegate.get();
        if (service != null) {
            service.execute(taskManager.trackTask(command));
            return;
        }
        throw new RejectedExecutionException(
                "Execution service is terminated. No more tasks can be executed.");
    }
View Full Code Here

      startStoreCoordinator();
   }

   private void startStoreCoordinator() {
      ExecutorService storeCoordinator = Executors.newFixedThreadPool(1);
      storeCoordinator.execute( new AsyncStoreCoordinator() );
      storeCoordinator.shutdown();
   }

   @Override
   public void stop() throws CacheLoaderException {
View Full Code Here

      final AtomicReference<Exception> throwableHolder = new AtomicReference<>();
      final CyclicBarrier counter = new CyclicBarrier(NUMBER_OF_THREADS);

      ExecutorService executorService = Executors.newFixedThreadPool(NUMBER_OF_THREADS);
      for(int i = 0; i < NUMBER_OF_THREADS; ++i) {
         executorService.execute(new Runnable() {
            @Override
            public void run() {
               try {
                  counter.await();
                  service.cacheResult("Thread " + Thread.currentThread().getId());
View Full Code Here

        for (ConfigurationResourceProvider p : RESOURCE_PROVIDERS) {
            FutureTask<Collection<URL>> t =
                 new FutureTask<Collection<URL>>(new URLTask(p, sc));
            urlTasks.add(t);
            if (executor != null) {
                executor.execute(t);
            } else {
                t.run();
            }
        }
View Full Code Here

                for (URL u : l) {
                    FutureTask<Document> d =
                         new FutureTask<Document>(new ParseTask(validating, u));
                    docTasks.add(d);
                    if (executor != null) {
                        executor.execute(d);
                    } else {
                        d.run();
                    }
                }
            } catch (InterruptedException ignored) {
View Full Code Here

    {
      sreader = new ServerReader(socket);
      swriter = new ServerWriter(socket);
     
      ExecutorService threadExecutorService = Executors.newSingleThreadExecutor();
      threadExecutorService.execute(sreader);
      threadExecutorService.shutdown();
    }
  }

  /**
 
View Full Code Here

            }
            if (op instanceof UrgentSystemOperation) {
                throw new IllegalStateException("UrgentSystemOperation " + op + " can't be executed on a custom " +
                        "executor with name: " + executorName);
            }
            executor.execute(new LocalOperationProcessor(op));
        }
    }

    @Override
    @SuppressWarnings("unchecked")
View Full Code Here

                } else {
                    ExecutorService executor = executionService.getExecutor(executorName);
                    if (executor == null) {
                        throw new IllegalStateException("Could not found executor with name: " + executorName);
                    }
                    executor.execute(new LocalOperationProcessor(op));
                }
            }
        } catch (Throwable e) {
            logger.severe(e);
        }
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.