Package java.util.concurrent

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


  @Override
  public ScheduledFuture<?> scheduleAtFixedRate(Runnable task, Date startTime, long period) {
    ScheduledExecutorService executor = getScheduledExecutor();
    long initialDelay = startTime.getTime() - System.currentTimeMillis();
    try {
      return executor.scheduleAtFixedRate(errorHandlingTask(task, true), initialDelay, period, TimeUnit.MILLISECONDS);
    }
    catch (RejectedExecutionException ex) {
      throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
  }
View Full Code Here


  @Override
  public ScheduledFuture<?> scheduleAtFixedRate(Runnable task, long period) {
    ScheduledExecutorService executor = getScheduledExecutor();
    try {
      return executor.scheduleAtFixedRate(errorHandlingTask(task, true), 0, period, TimeUnit.MILLISECONDS);
    }
    catch (RejectedExecutionException ex) {
      throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
  }
View Full Code Here

  public ScheduledFuture scheduleAtFixedRate(Runnable task, Date startTime, long period) {
    ScheduledExecutorService executor = getScheduledExecutor();
    long initialDelay = startTime.getTime() - System.currentTimeMillis();
    try {
      return executor.scheduleAtFixedRate(errorHandlingTask(task, true), initialDelay, period, TimeUnit.MILLISECONDS);
    }
    catch (RejectedExecutionException ex) {
      throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
  }
View Full Code Here

  }

  public ScheduledFuture scheduleAtFixedRate(Runnable task, long period) {
    ScheduledExecutorService executor = getScheduledExecutor();
    try {
      return executor.scheduleAtFixedRate(errorHandlingTask(task, true), 0, period, TimeUnit.MILLISECONDS);
    }
    catch (RejectedExecutionException ex) {
      throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
  }
View Full Code Here

    ScheduledExecutorService cleanerService = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
      public Thread newThread(Runnable runnable) {
        return new Thread(runnable, "imcache:bufferCleaner(name="+getName()+",thread="+ NO_OF_CLEANERS.incrementAndGet() + ")");
      }
    });
    cleanerService.scheduleAtFixedRate(new Runnable() {
      public void run() {
        cleanBuffers(bufferCleanerThreshold);
      }
    }, bufferCleanerPeriod, bufferCleanerPeriod, TimeUnit.MILLISECONDS);
    ScheduledExecutorService evictionService = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
View Full Code Here

    ScheduledExecutorService evictionService = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
      public Thread newThread(Runnable runnable) {
        return new Thread(runnable, "imcache:evictionService(name="+getName()+",thread="+ NO_OF_EVICTORS.incrementAndGet() + ")");
      }
    });
    evictionService.scheduleAtFixedRate(new Runnable() {
      public void run() {
        doEviction(evictionPeriod);
      }
    }, bufferCleanerPeriod, evictionPeriod, TimeUnit.MILLISECONDS);
  }
View Full Code Here

        final int FACTS_PER_POLL = 1000;
        final int POLL_INTERVAL = 500;

        ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
        executor.scheduleAtFixedRate(
                new Runnable() {

                    public void run() {
                        for ( int j = 0; j < FACTS_PER_POLL; j++ ) {
                            ksession.insert( new MyFact() );
View Full Code Here

                  }
                });
    latch.await();
    System.out.println("D2 client is sending traffic ");

    ScheduledFuture task = executorService.scheduleAtFixedRate(new Runnable()
    {
      @Override
      public void run ()
      {
        try
View Full Code Here

    latch.await();
    System.out.println("D2 client is sending traffic.");
    System.out.println("Note that traffic for 'member' will go mostly to ProfileService 1,3,5 servers.");
    System.out.println("Because we make ProfileService 2,4,6 servers respond slowly \n");

    ScheduledFuture task = executorService.scheduleAtFixedRate(new Runnable()
    {
      @Override
      public void run ()
      {
        try
View Full Code Here

                           "the threshold (high water mark).");
    System.out.println("===========================================================");
    System.in.read();
    task.cancel(false);

    task = executorService.scheduleAtFixedRate(new Runnable()
    {
      @Override
      public void run ()
      {
        try
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.