Top Description Fields Constructors Methods
org.springframework.scheduling.config

public Class IntervalTask

extends DelayedTask
Class Inheritance
Known Direct Subclasses
org.springframework.scheduling.config.FixedDelayTask, org.springframework.scheduling.config.FixedRateTask
Imports
java.time.Duration, org.springframework.util.Assert

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.
Authors
Chris Beams, Arjen Poutsma
Since
3.2
See Also
ScheduledTaskRegistrar#addFixedRateTask(IntervalTask), ScheduledTaskRegistrar#addFixedDelayTask(IntervalTask)

Field Summary

Modifier and TypeField and Description
private final Duration

Constructor Summary

AccessConstructor and Description
public
IntervalTask(Runnable
the underlying task to execute
runnable
,
long
how often in milliseconds the task should be executed
interval
,
long
the initial delay before first execution of the task
initialDelay
)
Deprecated since 6.0. as of 6.0, in favor on IntervalTask(Runnable, Duration, Duration)

Create a new IntervalTask.

public
IntervalTask(Runnable
the underlying task to execute
runnable
,
long
how often in milliseconds the task should be executed
interval
)
Deprecated since 6.0. as of 6.0, in favor on IntervalTask(Runnable, Duration)

Create a new IntervalTask with no initial delay.

public
IntervalTask(Runnable
the underlying task to execute
runnable
,
Duration
how often the task should be executed
interval
)

Create a new IntervalTask with no initial delay.

public
IntervalTask(Runnable
the underlying task to execute
runnable
,
Duration
how often the task should be executed
interval
,
Duration
the initial delay before first execution of the task
initialDelay
)

Create a new IntervalTask.

pack-priv
IntervalTask(IntervalTask task)

Copy constructor.

Method Summary

Modifier and TypeMethod and Description
public long
getInitialDelay()
Deprecated since 6.0. as of 6.0, in favor of getInitialDelayDuration()

Return the initial delay before first execution of the task.

public Duration
getInitialDelayDuration()

Overrides org.springframework.scheduling.config.DelayedTask.getInitialDelayDuration.

Return the initial delay before first execution of the task.

public long
getInterval()
Deprecated since 6.0. as of 6.0, in favor of getIntervalDuration()

Return how often in milliseconds the task should be executed.

public Duration
getIntervalDuration()

Return how often the task should be executed.

Field Detail

intervalback to summary
private final Duration interval

Constructor Detail

IntervalTaskback to summary
public IntervalTask(Runnable runnable, long interval, long initialDelay)

Deprecated

since 6.0.

as of 6.0, in favor on IntervalTask(Runnable, Duration, Duration)

Create a new IntervalTask.

Parameters
runnable:Runnable

the underlying task to execute

interval:long

how often in milliseconds the task should be executed

initialDelay:long

the initial delay before first execution of the task

Annotations
@Deprecated
since:6.0
IntervalTaskback to summary
public IntervalTask(Runnable runnable, long interval)

Deprecated

since 6.0.

as of 6.0, in favor on IntervalTask(Runnable, Duration)

Create a new IntervalTask with no initial delay.

Parameters
runnable:Runnable

the underlying task to execute

interval:long

how often in milliseconds the task should be executed

Annotations
@Deprecated
since:6.0
IntervalTaskback to summary
public IntervalTask(Runnable runnable, Duration interval)

Create a new IntervalTask with no initial delay.

Parameters
runnable:Runnable

the underlying task to execute

interval:Duration

how often the task should be executed

Since
6.0
IntervalTaskback to summary
public IntervalTask(Runnable runnable, Duration interval, Duration initialDelay)

Create a new IntervalTask.

Parameters
runnable:Runnable

the underlying task to execute

interval:Duration

how often the task should be executed

initialDelay:Duration

the initial delay before first execution of the task

Since
6.0
IntervalTaskback to summary
pack-priv IntervalTask(IntervalTask task)

Copy constructor.

Method Detail

getInitialDelayback to summary
public long getInitialDelay()

Deprecated

since 6.0.

as of 6.0, in favor of getInitialDelayDuration()

Return the initial delay before first execution of the task.

Annotations
@Deprecated
since:6.0
getInitialDelayDurationback to summary
public Duration getInitialDelayDuration()

Overrides org.springframework.scheduling.config.DelayedTask.getInitialDelayDuration.

Return the initial delay before first execution of the task.

Annotations
@Override
Since
6.0
getIntervalback to summary
public long getInterval()

Deprecated

since 6.0.

as of 6.0, in favor of getIntervalDuration()

Return how often in milliseconds the task should be executed.

Annotations
@Deprecated
since:6.0
getIntervalDurationback to summary
public Duration getIntervalDuration()

Return how often the task should be executed.

Since
6.0