Package java.util.concurrent

Examples of java.util.concurrent.ScheduledExecutorService.scheduleAtFixedRate()


    logger.debug("Awaiting async components for completion.");

    final CountDownLatch latch = new CountDownLatch(1);
    ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(1);
    ScheduledFuture<?> handle = executor.scheduleAtFixedRate(new Runnable() {
      @Override
      public void run() {

        // assure still in running state
        if (getState() != ProcessState.RUNNING) {
View Full Code Here


      return;

    final CountDownLatch latch = new CountDownLatch(1);

    ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(1);
    ScheduledFuture<?> handle = executor.scheduleAtFixedRate(new Runnable() {
      @Override
      public void run() {
        if (state == ProcessState.SUCCEEDED || state == ProcessState.FAILED)
          latch.countDown();
      }
View Full Code Here

                // wake every heartbeatSeconds / 2 to avoid the worst case
                // where the last activity comes just after the last heartbeat
                long interval = SECONDS.toNanos(heartbeatSeconds) / 2;
                ScheduledExecutorService executor = createExecutorIfNecessary();
                Runnable task = new HeartbeatRunnable(interval);
                this.future = executor.scheduleAtFixedRate(
                    task, interval, interval, TimeUnit.NANOSECONDS);
            }
        }
    }
View Full Code Here

                // wake every heartbeatSeconds / 2 to avoid the worst case
                // where the last activity comes just after the last heartbeat
                long interval = SECONDS.toNanos(heartbeatSeconds) / 2;
                ScheduledExecutorService executor = createExecutorIfNecessary();
                Runnable task = new HeartbeatRunnable(interval);
                this.future = executor.scheduleAtFixedRate(
                    task, interval, interval, TimeUnit.NANOSECONDS);
            }
        }
    }
View Full Code Here

                public void run()
                {
                    client.updateLastAccess();
                }
            };
            service.scheduleAtFixedRate(command, 10, 10, TimeUnit.MILLISECONDS);
            client.inTransaction().create().forPath("/foo", "data".getBytes()).and().commit();
            service.shutdownNow();
            Thread.sleep(2000);

            Assert.assertNull(client.getCleanup());
View Full Code Here

      public Thread newThread(Runnable runnable) {
        return new Thread(runnable, "imcache:batchAsyncEvictionDrainer(thread="
            + NO_OF_EVICTION_DRAINERS.incrementAndGet() + ")");
      }
    });
    drainerService.scheduleAtFixedRate(new Runnable() {
      public void run() {
        drainQueue();
      }
    }, period, period, TimeUnit.MILLISECONDS);
  }
View Full Code Here

        Runnable cleanSessionTask = new IdleSessionSweeper(sessionStore, sessionTTLinSec * 1000L);
        ScheduledExecutorService idleSessionChecker = Executors.newScheduledThreadPool(1);
        try {
            // start idle session sweeper
            idleSessionChecker.scheduleAtFixedRate(cleanSessionTask, sessionTTLinSec + 10L, sweepIntervalInSec, TimeUnit.SECONDS);
            // accept connections
            acceptConnections(initializer, port);
        } finally {
            // release threads
            idleSessionChecker.shutdownNow();
View Full Code Here

    this.bootstrap = bootstrap;
    context.setClientWorker(this);
    context.setApplicationContext(applicationContext);
    // 定时发送心跳
    ScheduledExecutorService service = Executors.newScheduledThreadPool(2);
    service.scheduleAtFixedRate(new Runnable() {
      private WorkerHeartBeat heartbeat = new WorkerHeartBeat();
      private int failCount = 0;

      @Override
      public void run() {
View Full Code Here

          log.error("heart beat error:", e);
        }
      }
    }, 0, 5, TimeUnit.SECONDS);

    service.scheduleAtFixedRate(new Runnable() {

      private void exLog(Job job,Exception e){
        try {
          JobHistory his = job.getJobContext().getJobHistory();
          String jlog = his.getLog().getContent();
View Full Code Here

  }
 
  public void init() throws Exception{
    zeusSchedule=new ZeusSchedule(applicationContext);
    ScheduledExecutorService service=Executors.newScheduledThreadPool(3);
    service.scheduleAtFixedRate(new Runnable() {
     
      @Override
      public void run() {
        try {
          update();
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.