ScheduledExecutorService.scheduleAtFixedRate

Submits a periodic action that becomes enabled first after the given initial delay, and subsequently with the given period; that is, executions will commence after {@code initialDelay}, then {@code initialDelay + period}, then {@code initialDelay + 2 * period}, and so on.

<p>The sequence of task executions continues indefinitely until one of the following exceptional completions occur: <ul> <li>The task is {@linkplain Future#cancel explicitly cancelled} via the returned future. <li>The executor terminates, also resulting in task cancellation. <li>An execution of the task throws an exception. In this case calling {@link Future#get() get} on the returned future will throw {@link ExecutionException}, holding the exception as its cause. </ul> Subsequent executions are suppressed. Subsequent calls to {@link Future#isDone isDone()} on the returned future will return {@code true}.

<p>If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute.

@param command the task to execute @param initialDelay the time to delay first execution @param period the period between successive executions @param unit the time unit of the initialDelay and period parameters @return a ScheduledFuture representing pending completion of the series of repeated tasks. The future's {@link Future#get() get()} method will never return normally, and will throw an exception upon task cancellation or abnormal termination of a task execution. @throws RejectedExecutionException if the task cannot be scheduled for execution @throws NullPointerException if command or unit is null @throws IllegalArgumentException if period less than or equal to zero

interface ScheduledExecutorService
scheduleAtFixedRate
(
Runnable command
,
Duration initialDelay
,
Duration period
)

Meta