Package java.util.concurrent

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


                    Handler_economypromote.promotionTask = CommandsEX.plugin.getServer().getScheduler().runTaskTimerAsynchronously(CommandsEX.plugin, new Runnable() {
                    @Override
                    public void run() {
                      // create ExecutorService to manage threads                       
                      ExecutorService threadExecutor = Executors.newFixedThreadPool(1);
                      threadExecutor.execute(new Runnable() {
                        @Override
                        public void run() {
                          Handler_economypromote.checkTimedPromotions();
                        }
                      });
View Full Code Here


                if (mainClass != null)
                    injector.getInstance(mainClass);

                final ExecutorService executor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("GovernatorStandaloneTerminator-%d").build());
                executor.execute(new Runnable() {
                        @Override
                        public void run() {
                            LOG.info("Waiting for terminate event");
                            try {
                                terminateEvent.await();
View Full Code Here

   *             if interrupted while waiting for endAllSignal.
   */
  private void doBatchWork(BatchBackend backend) throws InterruptedException {
    ExecutorService executor = Executors.newFixedThreadPool( typesToIndexInParallel, "BatchIndexingWorkspace" );
    for ( Class<?> type : rootEntities ) {
      executor.execute( new BatchIndexingWorkspace( gridDialect, searchFactoryImplementor, sessionFactory, type,
          cacheMode, endAllSignal, monitor, backend ) );
    }
    executor.shutdown();
    endAllSignal.await(); // waits for the executor to finish
  }
View Full Code Here

        if (isRunning && localIconsToRetrieve != null) {
          // Process icon requests outside the lock

          for (ServiceWizardMapEntry e : localIconsToRetrieve) {
            IconRetrieveRunnable r = new IconRetrieveRunnable(e);
            es.execute(r);
          }

          localIconsToRetrieve.clear();
        }
View Full Code Here

                final CopyOnWriteArrayList<Configuration> confs = new CopyOnWriteArrayList<Configuration>();

                for (int i = 0; i < MANAGED_SERVICES; i++)
                {
                    final String pid = "pid." + i + "-" + (pidCounter++);
                    executor.execute(new Runnable()
                    {
                        public void run()
                        {
                            Hashtable props = new Hashtable();
                            props.put(Constants.SERVICE_PID, pid);
View Full Code Here

                // Unregister managed services concurrently
                log.info("unregistering services concurrently");
                for (final ServiceRegistration sr : managedServices)
                {
                    executor.execute(new Runnable()
                    {
                        public void run()
                        {
                            sr.unregister();
                            managedServiceUnregistered.countDown();
View Full Code Here

        final AtomicBoolean passed = new AtomicBoolean(true);

        for(int i = 0; i < nRequests; i++) {
            final K key = getRequestKey();
            resourceInHand.putIfAbsent(key, new AtomicInteger(0));
            executor.execute(new Runnable() {

                public void run() {
                    try {
                        // borrow resource
                        V resource = pool.checkout(key);
View Full Code Here

            final CountDownLatch latch = new CountDownLatch(numRequests);
            final AtomicInteger index = new AtomicInteger(0);

            long start = System.nanoTime();
            for(int i = 0; i < numRequests; i++) {
                executor.execute(new Runnable() {

                    public void run() {
                        int current = index.getAndIncrement();
                        long begin = System.nanoTime();
                        try {
View Full Code Here

        // start a thread to do modifications
        ExecutorService executor = Executors.newFixedThreadPool(2);
        final Random rand = new Random();
        final AtomicInteger count = new AtomicInteger(0);
        final AtomicBoolean keepRunning = new AtomicBoolean(true);
        executor.execute(new Runnable() {

            public void run() {
                while(keepRunning.get()) {
                    byte[] bytes = Integer.toString(count.getAndIncrement()).getBytes();
                    store.put(new ByteArray(bytes), Versioned.value(bytes), null);
View Full Code Here

                    store.put(new ByteArray(bytes), Versioned.value(bytes), null);
                    count.incrementAndGet();
                }
            }
        });
        executor.execute(new Runnable() {

            public void run() {
                while(keepRunning.get()) {
                    byte[] bytes = Integer.toString(rand.nextInt(count.get())).getBytes();
                    store.delete(new ByteArray(bytes), new VectorClock());
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.