Package org.springframework.scheduling.config

# Class IntervalTask

java.lang.Object
org.springframework.scheduling.config.Task
org.springframework.scheduling.config.DelayedTask
org.springframework.scheduling.config.IntervalTask

Direct Known Subclasses:
  `FixedDelayTask`, `FixedRateTask`

public class IntervalTask extends DelayedTask
`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:
  - `ScheduledTaskRegistrar.addFixedRateTask(IntervalTask)`
  - `ScheduledTaskRegistrar.addFixedDelayTask(IntervalTask)`

## Constructor Summary

Constructors
Constructor
Description
`IntervalTask(Runnable runnable, long interval)`
Deprecated.
as of 6.0, in favor on `IntervalTask(Runnable, Duration)`
`IntervalTask(Runnable runnable, long interval, long initialDelay)`
Deprecated.
as of 6.0, in favor on `IntervalTask(Runnable, Duration, Duration)`
`IntervalTask(Runnable runnable, Duration interval)`
Create a new `IntervalTask` with no initial delay.
`IntervalTask(Runnable runnable, Duration interval, Duration initialDelay)`
Create a new `IntervalTask`.

## Method Summary

Modifier and Type
Method
Description
`long`
`getInitialDelay()`
Deprecated.
as of 6.0, in favor of `getInitialDelayDuration()`
`Duration`
`getInitialDelayDuration()`
Return the initial delay before first execution of the task.
`long`
`getInterval()`
Deprecated.
as of 6.0, in favor of `getIntervalDuration()`
`Duration`
`getIntervalDuration()`
Return how often the task should be executed.

### Methods inherited from class org.springframework.scheduling.config.Task

`getLastExecutionOutcome, getRunnable, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### IntervalTask

@Deprecated(since="6.0") public IntervalTask(Runnable runnable, long interval, long initialDelay)
Deprecated.
as of 6.0, in favor on `IntervalTask(Runnable, Duration, Duration)`
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.

Overrides:
  `getInitialDelayDuration` in class `DelayedTask`
Since:
  6.0