Package java.util.concurrent

Examples of java.util.concurrent.ExecutorService


  }

  private void handleDoWhile(final Node node) {
    // Executor thread is shutdown inside as thread gets killed when you
    // shutdown
    ExecutorService threadExecutor = Executors.newSingleThreadExecutor();
    DoWhileHandler doWhileHandler = new DoWhileHandler((DoWhileNode) node, this.invokerMap, getWaitingNodesDynamically(),
        getFinishedNodesDynamically(), this, threadExecutor);
    threadExecutor.submit(doWhileHandler);
  }
View Full Code Here


    _containerId = serverContainer.getContainerStaticConfig().getId();
    _outboundTrafficTotalStatsMBean =
        new ContainerTrafficTotalStats(_containerId, "outbound", enabled, threadSafe, null);
    _inboundTrafficTotalStatsMBean =
        new ContainerTrafficTotalStats(_containerId, "inbound", enabled, threadSafe, null);
    ExecutorService ioService = serverContainer.getIoExecutorService();
    _containerStats = new ContainerStats(_containerId, enabled, threadSafe, null,
                                         (ioService instanceof ThreadPoolExecutor) ? (ThreadPoolExecutor)ioService: null,
                                         serverContainer.getDefaultExecutorService());
    _outboundTrafficPerClientStats = new HashMap<String, ContainerTrafficTotalStats>(1000);
View Full Code Here

            Bytes.equals(VALUE, entry.getValue()));
      }
    }

    final Object waitLock = new Object();
    ExecutorService executorService = Executors.newFixedThreadPool(numVersions);
    final AtomicReference<AssertionError> error = new AtomicReference<AssertionError>(null);
    for (int versions = numVersions; versions < numVersions * 2; versions++) {
      final int versionsCopy = versions;
      executorService.submit(new Callable<Void>() {
        @Override
        public Void call() {
          try {
            Put put = new Put(ROW);
            put.add(FAMILY, QUALIFIER, ts + versionsCopy, VALUE);
            table.put(put);

            Result result = table.get(get);
            NavigableMap<Long, byte[]> navigableMap = result.getMap()
                .get(FAMILY).get(QUALIFIER);

            assertEquals("The number of versions of '" + Bytes.toString(FAMILY) + ":"
                + Bytes.toString(QUALIFIER) + " did not match " + versionsCopy, versionsCopy,
                navigableMap.size());
            for (Map.Entry<Long, byte[]> entry : navigableMap.entrySet()) {
              assertTrue("The value at time " + entry.getKey()
                  + " did not match what was put",
                  Bytes.equals(VALUE, entry.getValue()));
            }
            synchronized (waitLock) {
              waitLock.wait();
            }
          } catch (Exception e) {
          } catch (AssertionError e) {
            // the error happens in a thread, it won't fail the test,
            // need to pass it to the caller for proper handling.
            error.set(e);
            LOG.error(e);
          }

          return null;
        }
      });
    }
    synchronized (waitLock) {
      waitLock.notifyAll();
    }
    executorService.shutdownNow();
    assertNull(error.get());
  }
View Full Code Here

    public boolean isStarted() {
        return started.get();
    }

    private ServerBootstrap buildBootstrap(Config config) {
      ExecutorService bossExecutor = config.bossExecutor();
      if (bossExecutor == null) { bossExecutor = Executors.newCachedThreadPool(); }
      ExecutorService workerExecutor = config.workerExecutor();
      if (workerExecutor == null) { workerExecutor = Executors.newCachedThreadPool(); }
     
        final ServerBootstrap bootstrap = new ServerBootstrap(
                new NioServerSocketChannelFactory(bossExecutor, workerExecutor));
View Full Code Here

        final Configuration config = Configuration.create(Configuration.CONFIGURATION_SCHEMA_FILE, configFile, "");
        // Starting the Target
        final TargetServer target = new TargetServer(config);

        // Getting an Executor
        ExecutorService threadPool = Executors.newSingleThreadExecutor();
        // Starting the target
        threadPool.submit(target);

    }
View Full Code Here

    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.checkEcoPromotions();
          }
        });
        threadExecutor.shutdown(); // shutdown worker threads
      }
     
    }, (20 * taskTime), (20 * taskTime));
    // start listening on player quit events
    CommandsEX.plugin.getServer().getPluginManager().registerEvents(this, CommandsEX.plugin);
View Full Code Here

      Player player = (Player)sender;
     
      // check to which homes is player invited, if we didn't spam too much :)
      if (!Utils.checkCommandSpam(player, "home-list")) {
        // create ExecutorService to manage threads                       
        ExecutorService threadExecutor = Executors.newFixedThreadPool(1);
        threadExecutor.execute(new ListInvitedHomes(sender)); // execute the LIST command thread
        threadExecutor.shutdown(); // shutdown worker threads
      }
    } else {
      // no database, no homes
      LogHelper.showInfo("homeNoDatabase", sender);
    }
View Full Code Here

          LogHelper.showInfo("homeClearDaysNotNumeric", sender);
          return true;
        }
       
        // create ExecutorService to manage threads                       
        ExecutorService threadExecutor = Executors.newFixedThreadPool(1);
        threadExecutor.execute(new ClearOldHomes(sender, Integer.parseInt(args[1]))); // execute the ICLEAR command thread
        threadExecutor.shutdown(); // shutdown worker threads
      }
    } else {
      // no database, no homes
      LogHelper.showInfo("homeNoDatabase", sender);
    }
View Full Code Here

    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_playtimepromote.checkTimedPromotions();
          }
        });
        threadExecutor.shutdown(); // shutdown worker threads
      }
     
    }, (20 * taskTime), (20 * taskTime));
    // start listening on player quit events
    CommandsEX.plugin.getServer().getPluginManager().registerEvents(this, CommandsEX.plugin);
View Full Code Here

   * Saves the spawn database using Multiple Threads, this allows other things to happen while the database is saving
   * Not recommended to use this when the server is shutting down, otherwise the database could be closed before this can finish
   */
 
  public static void saveDatabaseMultiThreaded(){
    ExecutorService threadExecutor = Executors.newFixedThreadPool(1);
    threadExecutor.execute(new Runnable() {
      public void run() {
        saveDatabase();
      }
    });
    threadExecutor.shutdown();
  }
View Full Code Here

TOP

Related Classes of java.util.concurrent.ExecutorService

Copyright © 2018 www.massapicom. 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.