Class IntervalTask

java.lang.Object
org.springframework.scheduling.config.Task
org.springframework.scheduling.config.IntervalTask
Direct Known Subclasses:
FixedDelayTask, FixedRateTask

public class IntervalTask extends Task
Task implementation defining a Runnable to be executed at a given millisecond interval which may be treated as fixed-rate or fixed-delay depending on context.
Since:
3.2
Author:
Chris Beams, Arjen Poutsma
See Also:
  • Constructor Details

    • IntervalTask

      @Deprecated(since="6.0") public IntervalTask(Runnable runnable, long interval, long initialDelay)
      Deprecated.
      Create a new IntervalTask.
      Parameters:
      runnable - the underlying task to execute
      interval - how often in milliseconds the task should be executed
      initialDelay - the initial delay before first execution of the task
    • IntervalTask

      @Deprecated(since="6.0") public IntervalTask(Runnable runnable, long interval)
      Deprecated.
      as of 6.0, in favor on IntervalTask(Runnable, Duration)
      Create a new IntervalTask with no initial delay.
      Parameters:
      runnable - the underlying task to execute
      interval - how often in milliseconds the task should be executed
    • IntervalTask

      public IntervalTask(Runnable runnable, Duration interval)
      Create a new IntervalTask with no initial delay.
      Parameters:
      runnable - the underlying task to execute
      interval - how often the task should be executed
      Since:
      6.0
    • IntervalTask

      public IntervalTask(Runnable runnable, Duration interval, Duration initialDelay)
      Create a new IntervalTask.
      Parameters:
      runnable - the underlying task to execute
      interval - how often the task should be executed
      initialDelay - the initial delay before first execution of the task
      Since:
      6.0
  • Method Details

    • getInterval

      @Deprecated(since="6.0") public long getInterval()
      Deprecated.
      as of 6.0, in favor of getIntervalDuration()
      Return how often in milliseconds the task should be executed.
    • getIntervalDuration

      public Duration getIntervalDuration()
      Return how often the task should be executed.
      Since:
      6.0
    • getInitialDelay

      @Deprecated(since="6.0") public long getInitialDelay()
      Deprecated.
      as of 6.0, in favor of getInitialDelayDuration()
      Return the initial delay before first execution of the task.
    • getInitialDelayDuration

      public Duration getInitialDelayDuration()
      Return the initial delay before first execution of the task.
      Since:
      6.0