Interface SubmitterScheduler

    • Method Detail

      • schedule

        void schedule​(java.lang.Runnable task,
                      long delayInMs)
        Schedule a one time task with a given delay.
        Parameters:
        task - runnable to execute
        delayInMs - time in milliseconds to wait to execute task
      • scheduleWithFixedDelay

        void scheduleWithFixedDelay​(java.lang.Runnable task,
                                    long initialDelay,
                                    long recurringDelay)
        Schedule a fixed delay recurring task to run. The recurring delay time will be from the point where execution has finished. So the execution frequency is the recurringDelay + runtime for the provided task.

        Unlike ScheduledExecutorService if the task throws an exception, subsequent executions are NOT suppressed or prevented. So if the task throws an exception on every run, the task will continue to be executed at the provided recurring delay (possibly throwing an exception on each execution).

        Parameters:
        task - runnable to be executed
        initialDelay - delay in milliseconds until first run
        recurringDelay - delay in milliseconds for running task after last finish
      • scheduleAtFixedRate

        void scheduleAtFixedRate​(java.lang.Runnable task,
                                 long initialDelay,
                                 long period)
        Schedule a fixed rate recurring task to run. The recurring delay will be the same, regardless of how long task execution takes. A given runnable will not run concurrently (unless it is submitted to the scheduler multiple times). Instead of execution takes longer than the period, the next run will occur immediately (given thread availability in the pool).

        Unlike ScheduledExecutorService if the task throws an exception, subsequent executions are NOT suppressed or prevented. So if the task throws an exception on every run, the task will continue to be executed at the provided recurring delay (possibly throwing an exception on each execution).

        Parameters:
        task - runnable to be executed
        initialDelay - delay in milliseconds until first run
        period - amount of time in milliseconds between the start of recurring executions
      • submitScheduled

        default ListenableFuture<?> submitScheduled​(java.lang.Runnable task,
                                                    long delayInMs)
        Schedule a task with a given delay. There is a slight increase in load when using submitScheduled(Runnable, long) over schedule(Runnable, long). So this should only be used when the future is necessary.

        The Future.get() method will return null once the runnable has completed.

        Parameters:
        task - runnable to execute
        delayInMs - time in milliseconds to wait to execute task
        Returns:
        a future to know when the task has completed
      • submitScheduled

        <T> ListenableFuture<T> submitScheduled​(java.lang.Runnable task,
                                                T result,
                                                long delayInMs)
        Schedule a task with a given delay. The Future.get() method will return the provided result once the runnable has completed.
        Type Parameters:
        T - type of result returned from the future
        Parameters:
        task - runnable to execute
        result - result to be returned from resulting future .get() when runnable completes
        delayInMs - time in milliseconds to wait to execute task
        Returns:
        a future to know when the task has completed
      • submitScheduled

        <T> ListenableFuture<T> submitScheduled​(java.util.concurrent.Callable<T> task,
                                                long delayInMs)
        Schedule a Callable with a given delay. This is needed when a result needs to be consumed from the callable.
        Type Parameters:
        T - type of result returned from the future
        Parameters:
        task - callable to be executed
        delayInMs - time in milliseconds to wait to execute task
        Returns:
        a future to know when the task has completed and get the result of the callable