public interface TaskScheduler
Modifier and Type | Method and Description |
---|---|
<V> ScheduledFuture<V> |
schedule(Duration delay,
Callable<V> callable)
Creates and executes a ScheduledFuture that becomes enabled after the
given delay.
|
ScheduledFuture<?> |
schedule(Duration delay,
Runnable command)
Creates and executes a one-shot action that becomes enabled
after the given delay.
|
<V> ScheduledFuture<V> |
schedule(String cron,
Callable<V> command)
Creates and executes a one-shot action that becomes enabled
after the given delay.
|
ScheduledFuture<?> |
schedule(String cron,
Runnable command)
Creates and executes a one-shot action that becomes enabled
after the given delay.
|
default <V> ScheduledFuture<V> |
schedule(String cron,
String timezoneId,
Callable<V> command)
Creates and executes a one-shot action that becomes enabled
after the given delay.
|
default ScheduledFuture<?> |
schedule(String cron,
String timezoneId,
Runnable command)
Creates and executes a one-shot action that becomes enabled
after the given delay.
|
ScheduledFuture<?> |
scheduleAtFixedRate(Duration initialDelay,
Duration period,
Runnable command)
Creates and executes a periodic action that becomes enabled first
after the given initial delay, and subsequently with the given
period; that is executions will commence after
initialDelay then initialDelay+period , then
initialDelay + 2 * period , and so on. |
ScheduledFuture<?> |
scheduleWithFixedDelay(Duration initialDelay,
Duration delay,
Runnable command)
Creates and executes a periodic action that becomes enabled first
after the given initial delay, and subsequently with the
given delay between the termination of one execution and the
commencement of the next.
|
ScheduledFuture<?> schedule(String cron, Runnable command)
cron
- The cron expressioncommand
- the task to executeget()
method will return
null
upon completionRejectedExecutionException
- if the task cannot be
scheduled for executionNullPointerException
- if command or delay is null<V> ScheduledFuture<V> schedule(String cron, Callable<V> command)
V
- The type of the callable's resultcron
- The cron expressioncommand
- The task to executeget()
method will return
null
upon completionRejectedExecutionException
- if the task cannot be
scheduled for executionNullPointerException
- if command or delay is nulldefault ScheduledFuture<?> schedule(@NonNull String cron, @Nullable String timezoneId, @NonNull Runnable command)
cron
- The cron expressiontimezoneId
- The timezoneId to base the cron expression on. Defaults to system time zonecommand
- the task to executeget()
method will return
null
upon completionRejectedExecutionException
- if the task cannot be
scheduled for executionNullPointerException
- if command or delay is nulldefault <V> ScheduledFuture<V> schedule(@NonNull String cron, @Nullable String timezoneId, @NonNull Callable<V> command)
V
- The type of the callable's resultcron
- The cron expressiontimezoneId
- The time zone to base the cron expression on. Defaults to system time zonecommand
- The task to executeget()
method will return
null
upon completionRejectedExecutionException
- if the task cannot be
scheduled for executionNullPointerException
- if command or delay is nullScheduledFuture<?> schedule(Duration delay, Runnable command)
delay
- the time from now to delay executioncommand
- the task to executeget()
method will return
null
upon completionRejectedExecutionException
- if the task cannot be
scheduled for executionNullPointerException
- if command or delay is null<V> ScheduledFuture<V> schedule(Duration delay, Callable<V> callable)
V
- The type of the callable's resultdelay
- The time from now to delay executioncallable
- The function to executeRejectedExecutionException
- if the task cannot be
scheduled for executionNullPointerException
- if callable or delay is nullScheduledFuture<?> scheduleAtFixedRate(@Nullable Duration initialDelay, Duration period, Runnable command)
initialDelay
then initialDelay+period
, then
initialDelay + 2 * period
, and so on.
If any execution of the task
encounters an exception, subsequent executions are suppressed.
Otherwise, the task will only terminate via cancellation or
termination of the executor. If any execution of this task
takes longer than its period, then subsequent executions
may start late, but will not concurrently execute.initialDelay
- the time to delay first executionperiod
- the period between successive executionscommand
- the task to executeget()
method will throw an
exception upon cancellationRejectedExecutionException
- if the task cannot be
scheduled for executionNullPointerException
- if command or period is nullIllegalArgumentException
- if period less than or equal to zeroScheduledFuture<?> scheduleWithFixedDelay(@Nullable Duration initialDelay, Duration delay, Runnable command)
initialDelay
- the time to delay first executiondelay
- the delay between the termination of onecommand
- the task to execute
execution and the commencement of the nextget()
method will throw an
exception upon cancellationRejectedExecutionException
- if the task cannot be
scheduled for executionNullPointerException
- if command or delay is nullIllegalArgumentException
- if delay less than or equal to zero