Interface ListeningScheduledExecutorService
-
- All Superinterfaces:
Executor
,ExecutorService
,ListeningExecutorService
,ScheduledExecutorService
@GwtIncompatible public interface ListeningScheduledExecutorService extends ScheduledExecutorService, ListeningExecutorService
AScheduledExecutorService
that returnsListenableFuture
instances from itsExecutorService
methods. To create an instance from an existingScheduledExecutorService
, callMoreExecutors.listeningDecorator(ScheduledExecutorService)
.- Since:
- 10.0
- Author:
- Chris Povirk
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ListenableScheduledFuture<?>
schedule(Runnable command, long delay, TimeUnit unit)
Submits a one-shot task that becomes enabled after the given delay.<V extends @Nullable Object>
ListenableScheduledFuture<V>schedule(Callable<V> callable, long delay, TimeUnit unit)
Submits a value-returning one-shot task that becomes enabled after the given delay.ListenableScheduledFuture<?>
scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)
Submits a periodic action that becomes enabled first after the given initial delay, and subsequently with the given period; that is, executions will commence afterinitialDelay
, theninitialDelay + period
, theninitialDelay + 2 * period
, and so on.ListenableScheduledFuture<?>
scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
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.-
Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow
-
-
-
-
Method Detail
-
schedule
ListenableScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)
Description copied from interface:java.util.concurrent.ScheduledExecutorService
Submits a one-shot task that becomes enabled after the given delay.- Specified by:
schedule
in interfaceScheduledExecutorService
- Parameters:
command
- the task to executedelay
- the time from now to delay executionunit
- the time unit of the delay parameter- Returns:
- a ScheduledFuture representing pending completion of
the task and whose
get()
method will returnnull
upon completion - Since:
- 15.0 (previously returned ScheduledFuture)
-
schedule
<V extends @Nullable Object> ListenableScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit)
Description copied from interface:java.util.concurrent.ScheduledExecutorService
Submits a value-returning one-shot task that becomes enabled after the given delay.- Specified by:
schedule
in interfaceScheduledExecutorService
- Type Parameters:
V
- the type of the callable's result- Parameters:
callable
- the function to executedelay
- the time from now to delay executionunit
- the time unit of the delay parameter- Returns:
- a ScheduledFuture that can be used to extract result or cancel
- Since:
- 15.0 (previously returned ScheduledFuture)
-
scheduleAtFixedRate
ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)
Description copied from interface:java.util.concurrent.ScheduledExecutorService
Submits a periodic action that becomes enabled first after the given initial delay, and subsequently with the given period; that is, executions will commence afterinitialDelay
, theninitialDelay + period
, theninitialDelay + 2 * period
, and so on.The sequence of task executions continues indefinitely until one of the following exceptional completions occur:
- The task is explicitly cancelled via the returned future.
- The executor terminates, also resulting in task cancellation.
- An execution of the task throws an exception. In this case
calling
get
on the returned future will throwExecutionException
, holding the exception as its cause.
isDone()
on the returned future will returntrue
.If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute.
- Specified by:
scheduleAtFixedRate
in interfaceScheduledExecutorService
- Parameters:
command
- the task to executeinitialDelay
- the time to delay first executionperiod
- the period between successive executionsunit
- the time unit of the initialDelay and period parameters- Returns:
- a ScheduledFuture representing pending completion of
the series of repeated tasks. The future's
get()
method will never return normally, and will throw an exception upon task cancellation or abnormal termination of a task execution. - Since:
- 15.0 (previously returned ScheduledFuture)
-
scheduleWithFixedDelay
ListenableScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
Description copied from interface:java.util.concurrent.ScheduledExecutorService
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.The sequence of task executions continues indefinitely until one of the following exceptional completions occur:
- The task is explicitly cancelled via the returned future.
- The executor terminates, also resulting in task cancellation.
- An execution of the task throws an exception. In this case
calling
get
on the returned future will throwExecutionException
, holding the exception as its cause.
isDone()
on the returned future will returntrue
.- Specified by:
scheduleWithFixedDelay
in interfaceScheduledExecutorService
- Parameters:
command
- the task to executeinitialDelay
- the time to delay first executiondelay
- the delay between the termination of one execution and the commencement of the nextunit
- the time unit of the initialDelay and delay parameters- Returns:
- a ScheduledFuture representing pending completion of
the series of repeated tasks. The future's
get()
method will never return normally, and will throw an exception upon task cancellation or abnormal termination of a task execution. - Since:
- 15.0 (previously returned ScheduledFuture)
-
-