Package java.util.concurrent

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


    } 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


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

     * Due to the lack of contract in CDI guaranteeing when beans will be available, we use an
     * executor to search for the beans every 100ms until it finds them. Or, after a 25 seconds,
     * blow up if they don't become available.
     */
    final ScheduledExecutorService startupScheduler = Executors.newScheduledThreadPool(1);
    startupScheduler.scheduleAtFixedRate(new StartupCallback(beanManager, bus, startupScheduler, 25), 0, 100,
            TimeUnit.MILLISECONDS);

    for (final Class<?> remoteInterfaceType : managedTypes.getRemoteInterfaces()) {
      createRPCScaffolding(remoteInterfaceType, bus, beanManager);
    }
View Full Code Here

    /**
     * Due to the lack of contract in CDI guaranteeing when beans will be available, we use an executor to search for
     * the beans every 100ms until it finds them. Or, after a 25 seconds, blow up if they don't become available.
     */
    final ScheduledExecutorService startupScheduler = Executors.newScheduledThreadPool(1);
    startupScheduler.scheduleAtFixedRate(
        new StartupCallback(beanManager, bus, startupScheduler, 25), 0, 100, TimeUnit.MILLISECONDS);

    for (final Class<?> remoteInterfaceType : managedTypes.getRemoteInterfaces()) {
      createRPCScaffolding(remoteInterfaceType, bus, beanManager);
    }
View Full Code Here

    System.out.printf("Main: Starting at: %s\n",new Date());

    // Create a new task and sends it to the executor. It will start with a delay of 1 second and then
    // it will execute every two seconds
    Task task=new Task("Task");
    ScheduledFuture<?> result=executor.scheduleAtFixedRate(task, 1, 2, TimeUnit.SECONDS);
   
    // Controlling the execution of tasks
    for (int i=0; i<10; i++){
      System.out.printf("Main: Delay: %d\n",result.getDelay(TimeUnit.MILLISECONDS));
      try {
View Full Code Here

                    }
                    endpointSizeQueue.offer((int)(disruptorEndpoint.getBufferSize() - remainingCapacity));
                }
            }
        };
        service.scheduleAtFixedRate(monitoring, 0, 100, TimeUnit.MILLISECONDS);
        return service;
    }

    private void uninstallSizeMonitoring(final ExecutorService monitoring) {
        if (monitoring != null) {
View Full Code Here

    private void runRepeatedScheduling(String testName, boolean fixedRate) throws InterruptedException {
        SignallingRunnable runner = new SignallingRunnable(testName);
        ScheduledExecutorService executor = createScheduledThreadPoolExecutor();
        ScheduledFuture<?> future = fixedRate
                ? executor.scheduleAtFixedRate(runner, 25L, 135L, TimeUnit.MILLISECONDS)
                : executor.scheduleWithFixedDelay(runner, 25L, 135L, TimeUnit.MILLISECONDS);
        Thread thread = iterateRunner(runner);
        future.cancel(true);
        assertCurrentThreadExecution();
        assertLastExecutionOperation(thread);
View Full Code Here

        }
        if (getCompletionInterval() > 0) {
            LOG.info("Using CompletionInterval to run every " + getCompletionInterval() + " millis.");
            ScheduledExecutorService scheduler = camelContext.getExecutorServiceStrategy().newScheduledThreadPool(this, "AggregateTimeoutChecker", 1);
            // trigger completion based on interval
            scheduler.scheduleAtFixedRate(new AggregationIntervalTask(), 1000L, getCompletionInterval(), TimeUnit.MILLISECONDS);
        }

        // start timeout service if its in use
        if (getCompletionTimeout() > 0 || getCompletionTimeoutExpression() != null) {
            LOG.info("Using CompletionTimeout to trigger after " + getCompletionTimeout() + " millis of inactivity.");
View Full Code Here

        } catch (Exception ex) {
          ex.printStackTrace();
        }
      }
    };
    ses.scheduleAtFixedRate(sizer, 10, 10, TimeUnit.MILLISECONDS);

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
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.