Package java.util.concurrent

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


        try {
            final Future<E> taskFuture = service.submit(this.call);
            final Runnable t = new Runnable() {
                public void run() { taskFuture.cancel(true); }
            };
            service.execute(t);
            service.shutdown();
            try {
                return taskFuture.get(timeout, TimeUnit.MILLISECONDS);
            } catch (final CancellationException e) {
                // callable was interrupted
View Full Code Here


factory.setNewSessionListener(new Runnable()
{
  public void run()
  {
    stop = false;
    executor.execute(new Runnable()
    {
      public void run()
      {
          System.out.println("started work thread");
          Map options = new HashMap();
View Full Code Here

        main = borning.born(new Object[]{atoms, lock, server, service, saTable});

        if (log.isDebugEnabled())
          log.debug("Ready for listen");

        execs.execute(main);

        if (log.isDebugEnabled())
          log.debug("wait for accept ...");

        // 如果没有接受套接字,那么自旋判断是不是有一个连接提示要关闭整个监听
View Full Code Here

                    + " log " + e);
                e.printStackTrace();
              }
            }
          };
          threadPool.execute(thread);
        }
        threadPool.shutdown();
        // Wait for all threads to terminate
        try {
          for(int i = 0; !threadPool.awaitTermination(5, TimeUnit.SECONDS); i++) {
View Full Code Here

      @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();
          }
        });
View Full Code Here

     
      // 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

          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

      @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();
          }
        });
View Full Code Here

   * 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

                    Handler_playtimepromote.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();
                        }
                      });
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.