Package java.util.concurrent

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


          thread.setPriority(Thread.MIN_PRIORITY);
          return thread;
        }
      };
      ScheduledExecutorService executor = Executors.newScheduledThreadPool(1, factory);
      executor.scheduleAtFixedRate(new Runnable() {
        @Override
        public void run() {
          // This is not exactly thread-safe, but is OK for our use.
          // The only thread that writes the volatile is this task.
          generation = generation + 1;
View Full Code Here


    } else {
      a = address;
    }
   
    final Set<InstanceMapper> instanceMappers = new HashSet<>();
    re.scheduleAtFixedRate(new Runnable() {
      @Override
      public void run() {
        q.post(new Runnable() {
          @Override
          public void run() {
View Full Code Here

      a = address;
    }

    final Set<TelnetResponseReader> connections = new HashSet<>();
    if (callWithEmptyTime > 0d) {
      re.scheduleAtFixedRate(new Runnable() {
        @Override
        public void run() {
          q.post(new Runnable() {
            @Override
            public void run() {
View Full Code Here

    } else {
      a = address;
    }
   
    final Set<InstanceMapper> instanceMappers = new HashSet<>();
    re.scheduleAtFixedRate(new Runnable() {
      @Override
      public void run() {
        q.post(new Runnable() {
          @Override
          public void run() {
View Full Code Here

                }
            };

            final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
            if(period > 0) {
                scheduler.scheduleAtFixedRate(runnable, start, period, TimeUnit.MILLISECONDS);
            } else {
                scheduler.schedule(runnable, start, TimeUnit.MILLISECONDS);
            }

            schedulers.add(scheduler);
View Full Code Here

  @Test
  public void registerAfterShutdown() throws InterruptedException, ExecutionException {
    final ScheduledExecutorService scheduler = ExecutorServices.createScheduler();
    final List<Integer> pool = new ArrayList<Integer>();
    scheduler.scheduleAtFixedRate(new SleepingRunnable(1, 10, pool), 0, 100, TimeUnit.MILLISECONDS);
    final ExecutorService backgroundExecutor = ExecutorServices.createBackgroundExecutor();
    backgroundExecutor.submit(new SleepingRunnable(1, 100, pool));
    ExecutorServices.shutdownAll();
  }
View Full Code Here

  @Test
  public void scheduleUpdateOperation_executionOrderPredictableWhenSingleThreaded_1() throws InterruptedException, ExecutionException {
    final ScheduledExecutorService scheduler = ExecutorServices.createScheduler();
    final List<Integer> pool = new ArrayList<Integer>();
    final ScheduledFuture<?> f1 = scheduler.scheduleAtFixedRate(new SleepingRunnable(1, 10, pool), 0, 10, TimeUnit.MILLISECONDS);
    final ScheduledFuture<?> f2 = scheduler.scheduleAtFixedRate(new SleepingRunnable(2, 10, pool), 0, 10, TimeUnit.MILLISECONDS);
    final ScheduledFuture<?> f3 = scheduler.scheduleAtFixedRate(new SleepingRunnable(3, 10, pool), 0, 10, TimeUnit.MILLISECONDS);
    final ScheduledFuture<?> f4 = scheduler.scheduleAtFixedRate(new SleepingRunnable(4, 10, pool), 0, 10, TimeUnit.MILLISECONDS);
    final ScheduledFuture<?> f5 = scheduler.scheduleAtFixedRate(new SleepingRunnable(5, 50, pool), 0, 10, TimeUnit.MILLISECONDS);
    Thread.sleep(180);
View Full Code Here

  @Test
  public void scheduleUpdateOperation_executionOrderPredictableWhenSingleThreaded_1() throws InterruptedException, ExecutionException {
    final ScheduledExecutorService scheduler = ExecutorServices.createScheduler();
    final List<Integer> pool = new ArrayList<Integer>();
    final ScheduledFuture<?> f1 = scheduler.scheduleAtFixedRate(new SleepingRunnable(1, 10, pool), 0, 10, TimeUnit.MILLISECONDS);
    final ScheduledFuture<?> f2 = scheduler.scheduleAtFixedRate(new SleepingRunnable(2, 10, pool), 0, 10, TimeUnit.MILLISECONDS);
    final ScheduledFuture<?> f3 = scheduler.scheduleAtFixedRate(new SleepingRunnable(3, 10, pool), 0, 10, TimeUnit.MILLISECONDS);
    final ScheduledFuture<?> f4 = scheduler.scheduleAtFixedRate(new SleepingRunnable(4, 10, pool), 0, 10, TimeUnit.MILLISECONDS);
    final ScheduledFuture<?> f5 = scheduler.scheduleAtFixedRate(new SleepingRunnable(5, 50, pool), 0, 10, TimeUnit.MILLISECONDS);
    Thread.sleep(180);
    f1.cancel(true);
View Full Code Here

  public void scheduleUpdateOperation_executionOrderPredictableWhenSingleThreaded_1() throws InterruptedException, ExecutionException {
    final ScheduledExecutorService scheduler = ExecutorServices.createScheduler();
    final List<Integer> pool = new ArrayList<Integer>();
    final ScheduledFuture<?> f1 = scheduler.scheduleAtFixedRate(new SleepingRunnable(1, 10, pool), 0, 10, TimeUnit.MILLISECONDS);
    final ScheduledFuture<?> f2 = scheduler.scheduleAtFixedRate(new SleepingRunnable(2, 10, pool), 0, 10, TimeUnit.MILLISECONDS);
    final ScheduledFuture<?> f3 = scheduler.scheduleAtFixedRate(new SleepingRunnable(3, 10, pool), 0, 10, TimeUnit.MILLISECONDS);
    final ScheduledFuture<?> f4 = scheduler.scheduleAtFixedRate(new SleepingRunnable(4, 10, pool), 0, 10, TimeUnit.MILLISECONDS);
    final ScheduledFuture<?> f5 = scheduler.scheduleAtFixedRate(new SleepingRunnable(5, 50, pool), 0, 10, TimeUnit.MILLISECONDS);
    Thread.sleep(180);
    f1.cancel(true);
    f2.cancel(true);
View Full Code Here

    final ScheduledExecutorService scheduler = ExecutorServices.createScheduler();
    final List<Integer> pool = new ArrayList<Integer>();
    final ScheduledFuture<?> f1 = scheduler.scheduleAtFixedRate(new SleepingRunnable(1, 10, pool), 0, 10, TimeUnit.MILLISECONDS);
    final ScheduledFuture<?> f2 = scheduler.scheduleAtFixedRate(new SleepingRunnable(2, 10, pool), 0, 10, TimeUnit.MILLISECONDS);
    final ScheduledFuture<?> f3 = scheduler.scheduleAtFixedRate(new SleepingRunnable(3, 10, pool), 0, 10, TimeUnit.MILLISECONDS);
    final ScheduledFuture<?> f4 = scheduler.scheduleAtFixedRate(new SleepingRunnable(4, 10, pool), 0, 10, TimeUnit.MILLISECONDS);
    final ScheduledFuture<?> f5 = scheduler.scheduleAtFixedRate(new SleepingRunnable(5, 50, pool), 0, 10, TimeUnit.MILLISECONDS);
    Thread.sleep(180);
    f1.cancel(true);
    f2.cancel(true);
    f3.cancel(true);
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.