Top Description Methods
com.google.common.util.concurrent

public Interface ListeningScheduledExecutorService

extends ScheduledExecutorService, ListeningExecutorService
Known Direct Implementers
com.google.common.util.concurrent.MoreExecutors.ScheduledListeningDecorator
Annotations
@J2ktIncompatible
@GwtIncompatible
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.util.concurrent.Internal.toNanosSaturated

A ScheduledExecutorService that returns ListenableFuture instances from its ExecutorService methods. To create an instance from an existing ScheduledExecutorService, call MoreExecutors#listeningDecorator(ScheduledExecutorService).
Author
Chris Povirk
Since
10.0

Method Summary

Modifier and TypeMethod and Description
public ListenableScheduledFuture<?>
schedule(Runnable
the task to execute
command
,
long
the time from now to delay execution
delay
,
TimeUnit
the time unit of the delay parameter
unit
)

Redeclares java.util.concurrent.ScheduledExecutorService.schedule.

Submits a one-shot task that becomes enabled after the given delay.
public default ListenableScheduledFuture<?>
schedule(Runnable command, Duration delay)

Duration-based overload of schedule(Runnable, long, TimeUnit).

public <V extends @Nullable Object> ListenableScheduledFuture<V>
schedule(Callable<V>
the function to execute
callable
,
long
the time from now to delay execution
delay
,
TimeUnit
the time unit of the delay parameter
unit
)

Redeclares java.util.concurrent.ScheduledExecutorService.schedule.

Submits a value-returning one-shot task that becomes enabled after the given delay.
public default <V extends @Nullable Object> ListenableScheduledFuture<V>
schedule(Callable<V> callable, Duration delay)

Duration-based overload of schedule(Callable, long, TimeUnit).

public ListenableScheduledFuture<?>
scheduleAtFixedRate(Runnable
the task to execute
command
,
long
the time to delay first execution
initialDelay
,
long
the period between successive executions
period
,
TimeUnit
the time unit of the initialDelay and period parameters
unit
)

Redeclares java.util.concurrent.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 initialDelay, then initialDelay + period, then initialDelay + 2 * period, and so on.
public default ListenableScheduledFuture<?>
scheduleAtFixedRate(Runnable command, Duration initialDelay, Duration period)

Duration-based overload of scheduleAtFixedRate(Runnable, long, long, TimeUnit).

public ListenableScheduledFuture<?>
scheduleWithFixedDelay(Runnable
the task to execute
command
,
long
the time to delay first execution
initialDelay
,
long
the delay between the termination of one execution and the commencement of the next
delay
,
TimeUnit
the time unit of the initialDelay and delay parameters
unit
)

Redeclares java.util.concurrent.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.
public default ListenableScheduledFuture<?>
Inherited from com.google.common.util.concurrent.ListeningExecutorService:
awaitTerminationinvokeAllinvokeAllinvokeAllinvokeAnysubmitsubmitsubmit

Method Detail

scheduleback to summary
public ListenableScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)

Redeclares java.util.concurrent.ScheduledExecutorService.schedule.

Doc from java.util.concurrent.ScheduledExecutorService.schedule.

Submits a one-shot task that becomes enabled after the given delay.

Parameters
command:Runnable

the task to execute

delay:long

the time from now to delay execution

unit:TimeUnit

the time unit of the delay parameter

Returns:ListenableScheduledFuture<?>

a ScheduledFuture representing pending completion of the task and whose get() method will return null upon completion

Annotations
@Override
Since
15.0 (previously returned ScheduledFuture)
scheduleback to summary
public default ListenableScheduledFuture<?> schedule(Runnable command, Duration delay)

Duration-based overload of schedule(Runnable, long, TimeUnit).

Since
29.0
scheduleback to summary
public <V extends @Nullable Object> ListenableScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit)

Redeclares java.util.concurrent.ScheduledExecutorService.schedule.

Doc from java.util.concurrent.ScheduledExecutorService.schedule.

Submits a value-returning one-shot task that becomes enabled after the given delay.

Parameters
<V>
the type of the callable's result
callable:Callable<V>

the function to execute

delay:long

the time from now to delay execution

unit:TimeUnit

the time unit of the delay parameter

Returns:ListenableScheduledFuture<V>

a ScheduledFuture that can be used to extract result or cancel

Annotations
@Override
Since
15.0 (previously returned ScheduledFuture)
scheduleback to summary
public default <V extends @Nullable Object> ListenableScheduledFuture<V> schedule(Callable<V> callable, Duration delay)

Duration-based overload of schedule(Callable, long, TimeUnit).

Since
29.0
scheduleAtFixedRateback to summary
public ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)

Redeclares java.util.concurrent.ScheduledExecutorService.scheduleAtFixedRate.

Doc from java.util.concurrent.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 initialDelay, then initialDelay + period, then initialDelay + 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 throw ExecutionException, holding the exception as its cause.
Subsequent executions are suppressed. Subsequent calls to isDone() on the returned future will return true.

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

Parameters
command:Runnable

the task to execute

initialDelay:long

the time to delay first execution

period:long

the period between successive executions

unit:TimeUnit

the time unit of the initialDelay and period parameters

Returns:ListenableScheduledFuture<?>

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.

Annotations
@Override
Since
15.0 (previously returned ScheduledFuture)
scheduleAtFixedRateback to summary
public default ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, Duration initialDelay, Duration period)

Duration-based overload of scheduleAtFixedRate(Runnable, long, long, TimeUnit).

Since
29.0
scheduleWithFixedDelayback to summary
public ListenableScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)

Redeclares java.util.concurrent.ScheduledExecutorService.scheduleWithFixedDelay.

Doc from java.util.concurrent.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.

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 throw ExecutionException, holding the exception as its cause.
Subsequent executions are suppressed. Subsequent calls to isDone() on the returned future will return true.
Parameters
command:Runnable

the task to execute

initialDelay:long

the time to delay first execution

delay:long

the delay between the termination of one execution and the commencement of the next

unit:TimeUnit

the time unit of the initialDelay and delay parameters

Returns:ListenableScheduledFuture<?>

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.

Annotations
@Override
Since
15.0 (previously returned ScheduledFuture)
scheduleWithFixedDelayback to summary
public default ListenableScheduledFuture<?> scheduleWithFixedDelay(Runnable command, Duration initialDelay, Duration delay)

Duration-based overload of scheduleWithFixedDelay(Runnable, long, long, TimeUnit).

Since
29.0