Package org.apache.flink.util.concurrent
Class ScheduledExecutorServiceAdapter
- java.lang.Object
-
- org.apache.flink.util.concurrent.ScheduledExecutorServiceAdapter
-
- All Implemented Interfaces:
Executor,ScheduledExecutor
public class ScheduledExecutorServiceAdapter extends Object implements ScheduledExecutor
Adapter class for aScheduledExecutorServicewhich shall be used as aScheduledExecutor.
-
-
Constructor Summary
Constructors Constructor Description ScheduledExecutorServiceAdapter(ScheduledExecutorService scheduledExecutorService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute(Runnable command)ScheduledFuture<?>schedule(Runnable command, long delay, TimeUnit unit)Executes the given command after the given delay.<V> ScheduledFuture<V>schedule(Callable<V> callable, long delay, TimeUnit unit)Executes the given callable after the given delay.ScheduledFuture<?>scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)Executes the given command periodically.ScheduledFuture<?>scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)Executed the given command repeatedly with the given delay between the end of an execution and the start of the next execution.
-
-
-
Constructor Detail
-
ScheduledExecutorServiceAdapter
public ScheduledExecutorServiceAdapter(ScheduledExecutorService scheduledExecutorService)
-
-
Method Detail
-
schedule
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)
Description copied from interface:ScheduledExecutorExecutes the given command after the given delay.- Specified by:
schedulein interfaceScheduledExecutor- Parameters:
command- the task to execute in the futuredelay- the time from now to delay the executionunit- the time unit of the delay parameter- Returns:
- a ScheduledFuture representing the completion of the scheduled task
-
schedule
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit)
Description copied from interface:ScheduledExecutorExecutes the given callable after the given delay. The result of the callable is returned as aScheduledFuture.- Specified by:
schedulein interfaceScheduledExecutor- Type Parameters:
V- result type of the callable- Parameters:
callable- the callable to executedelay- the time from now to delay the executionunit- the time unit of the delay parameter- Returns:
- a ScheduledFuture which holds the future value of the given callable
-
scheduleAtFixedRate
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)
Description copied from interface:ScheduledExecutorExecutes the given command periodically. The first execution is started after theinitialDelay, the second execution is started afterinitialDelay + period, the third afterinitialDelay + 2*periodand so on. The task is executed until either an execution fails, or the returnedScheduledFutureis cancelled.- Specified by:
scheduleAtFixedRatein interfaceScheduledExecutor- Parameters:
command- the task to be executed periodicallyinitialDelay- the time from now until the first execution is triggeredperiod- the time after which the next execution is triggeredunit- the time unit of the delay and period parameter- Returns:
- a ScheduledFuture representing the periodic task. This future never completes unless an execution of the given task fails or if the future is cancelled
-
scheduleWithFixedDelay
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
Description copied from interface:ScheduledExecutorExecuted the given command repeatedly with the given delay between the end of an execution and the start of the next execution. The task is executed repeatedly until either an exception occurs or if the returnedScheduledFutureis cancelled.- Specified by:
scheduleWithFixedDelayin interfaceScheduledExecutor- Parameters:
command- the task to execute repeatedlyinitialDelay- the time from now until the first execution is triggereddelay- the time between the end of the current and the start of the next executionunit- the time unit of the initial delay and the delay parameter- Returns:
- a ScheduledFuture representing the repeatedly executed task. This future never completes unless the execution of the given task fails or if the future is cancelled
-
-