ScheduledExecutorService.scheduleWithFixedDelay

Submits 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.

<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}.

@param command the task to execute @param initialDelay the time to delay first execution @param delay the delay between the termination of one execution and the commencement of the next @param unit the time unit of the initialDelay and delay 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 delay less than or equal to zero

interface ScheduledExecutorService
scheduleWithFixedDelay
(
Runnable command
,
Duration initialDelay
,
Duration delay
)

Meta