Top Description Inners Fields Constructors Methods
reactor.core.scheduler

pack-priv final Class DelegateServiceScheduler

extends Object
implements Scheduler, SchedulerState.DisposeAwaiter<ScheduledExecutorService>, Scannable
Class Inheritance
All Implemented Interfaces
reactor.core.Scannable, reactor.core.scheduler.SchedulerState.DisposeAwaiter, reactor.core.scheduler.Scheduler, reactor.core.Disposable
Imports
java.time.Duration, java.util.Collection, .List, java.util.concurrent.Callable, .ExecutionException, .ExecutorService, .Executors, .Future, .ScheduledExecutorService, .ScheduledFuture, .TimeUnit, .TimeoutException, java.util.concurrent.atomic.AtomicReferenceFieldUpdater, java.util.function.Supplier, reactor.core.Disposable, .Exceptions, .Scannable, reactor.core.publisher.Mono, reactor.util.annotation.NonNull, .Nullable

A simple Scheduler which uses a backing ExecutorService to schedule Runnables for async operators. This scheduler is time-capable (can schedule with a delay and/or periodically) if the backing executor is a ScheduledExecutorService.
Authors
Stephane Maldini, Simon Baslé

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv final String
pack-priv final ScheduledExecutorService
pack-priv volatile SchedulerState<ScheduledExecutorService>
pack-priv static final AtomicReferenceFieldUpdater<DelegateServiceScheduler, SchedulerState<T>>
pack-priv static final ScheduledExecutorService

Constructor Summary

AccessConstructor and Description
pack-priv
DelegateServiceScheduler(String executorName, ExecutorService executorService)

Method Summary

Modifier and TypeMethod and Description
public boolean
pack-priv static ScheduledExecutorService
public Scheduler.Worker
createWorker()

Implements reactor.core.scheduler.Scheduler.createWorker.

Creates a worker of this Scheduler.
public void
dispose()

Overrides default reactor.core.scheduler.Scheduler.dispose.

Instructs this Scheduler to release all resources and reject any new tasks to be executed.
public Mono<Void>
disposeGracefully()

Overrides default reactor.core.scheduler.Scheduler.disposeGracefully.

Lazy variant of dispose() that also allows for graceful cleanup of underlying resources.
pack-priv ScheduledExecutorService
public void
init()

Overrides default reactor.core.scheduler.Scheduler.init.

Instructs this Scheduler to prepare itself for running tasks directly or through its Workers.
public boolean
isDisposed()

Overrides default reactor.core.Disposable.isDisposed.

Optionally return true when the resource or task is disposed.
public Object
scanUnsafe(Scannable.Attr<T>
a Attr to resolve for the component.
key
)

Implements reactor.core.Scannable.scanUnsafe.

This method is used internally by components to define their key-value mappings in a single place.
public Disposable
schedule(Runnable
the task to execute
task
)

Implements reactor.core.scheduler.Scheduler.schedule.

Schedules the non-delayed execution of the given task on this scheduler.
public Disposable
schedule(Runnable
the task to schedule
task
,
long
the delay amount, non-positive values indicate non-delayed scheduling
delay
,
TimeUnit
the unit of measure of the delay amount
unit
)

Overrides default reactor.core.scheduler.Scheduler.schedule.

Schedules the execution of the given task with the given delay amount.
public Disposable
schedulePeriodically(Runnable
the task to schedule
task
,
long
the initial delay amount, non-positive values indicate non-delayed scheduling
initialDelay
,
long
the period at which the task should be re-executed
period
,
TimeUnit
the unit of measure of the delay amount
unit
)

Overrides default reactor.core.scheduler.Scheduler.schedulePeriodically.

Schedules a periodic execution of the given task with the given initial delay and period.
public void
start()

Overrides default reactor.core.scheduler.Scheduler.start.

Instructs this Scheduler to prepare itself for running tasks directly or through its Workers.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

executorNameback to summary
pack-priv final String executorName
originalback to summary
pack-priv final ScheduledExecutorService original
stateback to summary
pack-priv volatile SchedulerState<ScheduledExecutorService> state
Annotations
@Nullable
STATEback to summary
pack-priv static final AtomicReferenceFieldUpdater<DelegateServiceScheduler, SchedulerState<T>> STATE
Annotations
@SuppressWarnings:rawtypes
TERMINATEDback to summary
pack-priv static final ScheduledExecutorService TERMINATED

Constructor Detail

DelegateServiceSchedulerback to summary
pack-priv DelegateServiceScheduler(String executorName, ExecutorService executorService)

Method Detail

awaitback to summary
public boolean await(ScheduledExecutorService resource, long timeout, TimeUnit timeUnit) throws InterruptedException

Implements reactor.core.scheduler.SchedulerState.DisposeAwaiter.await.

Annotations
@Override
convertback to summary
pack-priv static ScheduledExecutorService convert(ExecutorService executor)
Annotations
@SuppressWarnings:unchecked
createWorkerback to summary
public Scheduler.Worker createWorker()

Implements reactor.core.scheduler.Scheduler.createWorker.

Doc from reactor.core.scheduler.Scheduler.createWorker.

Creates a worker of this Scheduler.

Once the Worker is no longer in use, one should call dispose() on it to release any resources the particular Scheduler may have used. It depends on the implementation, but Scheduler Workers should usually run tasks in FIFO order. Some implementations may entirely delegate the scheduling to an underlying structure (like an ExecutorService).

Returns:Scheduler.Worker

the Worker instance.

Annotations
@Override
disposeback to summary
public void dispose()

Overrides default reactor.core.scheduler.Scheduler.dispose.

Doc from reactor.core.scheduler.Scheduler.dispose.

Instructs this Scheduler to release all resources and reject any new tasks to be executed.

The operation is thread-safe.

The Scheduler may choose to ignore this instruction.

When used in combination with disposeGracefully() there are no guarantees that all resources will be forcefully shutdown. When a graceful disposal has started, the references to the underlying java.util.concurrent.Executors might have already been lost.

Annotations
@Override
disposeGracefullyback to summary
public Mono<Void> disposeGracefully()

Overrides default reactor.core.scheduler.Scheduler.disposeGracefully.

Doc from reactor.core.scheduler.Scheduler.disposeGracefully.

Lazy variant of dispose() that also allows for graceful cleanup of underlying resources.

It is advised to apply a Mono#timeout(Duration) operator to the resulting Mono.

The returned Mono can be retried in case of timeout errors. It can also be followed by a call to dispose() to issue a forceful shutdown of underlying resources.

Returns:Mono<Void>

Mono which upon subscription initiates the graceful dispose procedure. If the disposal is successful, the returned Mono completes without an error.

Annotations
@Override
getOrCreateback to summary
pack-priv ScheduledExecutorService getOrCreate()
initback to summary
public void init()

Overrides default reactor.core.scheduler.Scheduler.init.

Doc from reactor.core.scheduler.Scheduler.init.

Instructs this Scheduler to prepare itself for running tasks directly or through its Workers.

Implementations are encouraged to throw an exception if this method is called after the scheduler has been disposed via dispose() or disposeGracefully().

Annotations
@Override
isDisposedback to summary
public boolean isDisposed()

Overrides default reactor.core.Disposable.isDisposed.

Doc from reactor.core.Disposable.isDisposed.

Optionally return true when the resource or task is disposed.

Implementations are not required to track disposition and as such may never return true even when disposed. However, they MUST only return true when there's a guarantee the resource or task is disposed.

Returns:boolean

true when there's a guarantee the resource or task is disposed.

Annotations
@Override
scanUnsafeback to summary
public Object scanUnsafe(Scannable.Attr<T> key)

Implements reactor.core.Scannable.scanUnsafe.

Doc from reactor.core.Scannable.scanUnsafe.

This method is used internally by components to define their key-value mappings in a single place. Although it is ignoring the generic type of the Attr key, implementors should take care to return values of the correct type, and return null if no specific value is available.

For public consumption of attributes, prefer using scan(Attr), which will return a typed value and fall back to the key's default if the component didn't define any mapping.

Parameters
key:Scannable.Attr<T>

a Attr to resolve for the component.

Returns:Object

the value associated to the key for that specific component, or null if none.

Annotations
@Override
scheduleback to summary
public Disposable schedule(Runnable task)

Implements reactor.core.scheduler.Scheduler.schedule.

Doc from reactor.core.scheduler.Scheduler.schedule.

Schedules the non-delayed execution of the given task on this scheduler.

This method is safe to be called from multiple threads but there are no ordering guarantees between tasks.

Parameters
task:Runnable

the task to execute

Returns:Disposable

the Disposable instance that let's one cancel this particular task. If the Scheduler has been shut down, throw a RejectedExecutionException.

Annotations
@Override
scheduleback to summary
public Disposable schedule(Runnable task, long delay, TimeUnit unit)

Overrides default reactor.core.scheduler.Scheduler.schedule.

Doc from reactor.core.scheduler.Scheduler.schedule.

Schedules the execution of the given task with the given delay amount.

This method is safe to be called from multiple threads but there are no ordering guarantees between tasks.

Parameters
task:Runnable

the task to schedule

delay:long

the delay amount, non-positive values indicate non-delayed scheduling

unit:TimeUnit

the unit of measure of the delay amount

Returns:Disposable

the Disposable that let's one cancel this particular delayed task, or throw a RejectedExecutionException if the Scheduler is not capable of scheduling with delay.

Annotations
@Override
schedulePeriodicallyback to summary
public Disposable schedulePeriodically(Runnable task, long initialDelay, long period, TimeUnit unit)

Overrides default reactor.core.scheduler.Scheduler.schedulePeriodically.

Doc from reactor.core.scheduler.Scheduler.schedulePeriodically.

Schedules a periodic execution of the given task with the given initial delay and period.

This method is safe to be called from multiple threads but there are no ordering guarantees between tasks.

The periodic execution is at a fixed rate, that is, the first execution will be after the initial delay, the second after initialDelay + period, the third after initialDelay + 2 * period, and so on.

Parameters
task:Runnable

the task to schedule

initialDelay:long

the initial delay amount, non-positive values indicate non-delayed scheduling

period:long

the period at which the task should be re-executed

unit:TimeUnit

the unit of measure of the delay amount

Returns:Disposable

the Disposable that let's one cancel this particular delayed task, or throw a RejectedExecutionException if the Scheduler is not capable of scheduling periodically.

Annotations
@Override
startback to summary
public void start()

Overrides default reactor.core.scheduler.Scheduler.start.

Doc from reactor.core.scheduler.Scheduler.start.

Instructs this Scheduler to prepare itself for running tasks directly or through its Workers.

The operation is thread-safe but one should avoid using start() and dispose() concurrently as it would non-deterministically leave the Scheduler in either active or inactive state.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
reactor.core.scheduler back to summary

pack-priv final Class DelegateServiceScheduler.UnsupportedScheduledExecutorService

extends Object
implements ScheduledExecutorService, Supplier<ExecutorService>
Class Inheritance
  • java.lang.Object
  • reactor.core.scheduler.DelegateServiceScheduler.UnsupportedScheduledExecutorService
All Implemented Interfaces
java.util.function.Supplier, java.util.concurrent.ScheduledExecutorService, java.util.concurrent.ExecutorService, java.lang.AutoCloseable, java.util.concurrent.Executor

Field Summary

Modifier and TypeField and Description
pack-priv final ExecutorService

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
awaitTermination(long
the maximum time to wait
timeout
,
TimeUnit
the time unit of the timeout argument
unit
)

Implements java.util.concurrent.ExecutorService.awaitTermination.

Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
public void
execute(Runnable
the runnable task
command
)

Implements java.util.concurrent.Executor.execute.

Executes the given command at some time in the future.
public ExecutorService
get()

Implements java.util.function.Supplier.get.

Gets a result.
public <T> List<Future<T>>
invokeAll(Collection<? extends Callable<T>>
the collection of tasks
tasks
)

Implements java.util.concurrent.ExecutorService.invokeAll.

Executes the given tasks, returning a list of Futures holding their status and results when all complete.
public <T> List<Future<T>>
invokeAll(Collection<? extends Callable<T>>
the collection of tasks
tasks
,
long
the maximum time to wait
timeout
,
TimeUnit
the time unit of the timeout argument
unit
)

Implements java.util.concurrent.ExecutorService.invokeAll.

Executes the given tasks, returning a list of Futures holding their status and results when all complete or the timeout expires, whichever happens first.
public <T> T
invokeAny(Collection<? extends Callable<T>>
the collection of tasks
tasks
)

Implements java.util.concurrent.ExecutorService.invokeAny.

Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do.
public <T> T
invokeAny(Collection<? extends Callable<T>>
the collection of tasks
tasks
,
long
the maximum time to wait
timeout
,
TimeUnit
the time unit of the timeout argument
unit
)

Implements java.util.concurrent.ExecutorService.invokeAny.

Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do before the given timeout elapses.
public boolean
isShutdown()

Implements java.util.concurrent.ExecutorService.isShutdown.

Returns true if this executor has been shut down.
public boolean
isTerminated()

Implements java.util.concurrent.ExecutorService.isTerminated.

Returns true if all tasks have completed following shut down.
public ScheduledFuture<?>
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
)

Implements java.util.concurrent.ScheduledExecutorService.schedule.

Submits a one-shot task that becomes enabled after the given delay.
public <V> ScheduledFuture<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
)

Implements java.util.concurrent.ScheduledExecutorService.schedule.

Submits a value-returning one-shot task that becomes enabled after the given delay.
public ScheduledFuture<?>
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
)

Implements 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 ScheduledFuture<?>
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
)

Implements 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 void
shutdown()

Implements java.util.concurrent.ExecutorService.shutdown.

Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.
public List<Runnable>
shutdownNow()

Implements java.util.concurrent.ExecutorService.shutdownNow.

Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution.
public <T> Future<T>
submit(Callable<T>
the task to submit
task
)

Implements java.util.concurrent.ExecutorService.submit.

Submits a value-returning task for execution and returns a Future representing the pending results of the task.
public <T> Future<T>
submit(Runnable
the task to submit
task
,
T
the result to return
result
)

Implements java.util.concurrent.ExecutorService.submit.

Submits a Runnable task for execution and returns a Future representing that task.
public Future<?>
submit(Runnable
the task to submit
task
)

Implements java.util.concurrent.ExecutorService.submit.

Submits a Runnable task for execution and returns a Future representing that task.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

execback to summary
pack-priv final ExecutorService exec

Constructor Detail

UnsupportedScheduledExecutorServiceback to summary
pack-priv UnsupportedScheduledExecutorService(ExecutorService exec)

Method Detail

awaitTerminationback to summary
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException

Implements java.util.concurrent.ExecutorService.awaitTermination.

Doc from java.util.concurrent.ExecutorService.awaitTermination.

Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.

Parameters
timeout:long

the maximum time to wait

unit:TimeUnit

the time unit of the timeout argument

Returns:boolean

true if this executor terminated and false if the timeout elapsed before termination

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting
executeback to summary
public void execute(Runnable command)

Implements java.util.concurrent.Executor.execute.

Doc from java.util.concurrent.Executor.execute.

Executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the Executor implementation.

Parameters
command:Runnable

the runnable task

Annotations
@Override
getback to summary
public ExecutorService get()

Implements java.util.function.Supplier.get.

Doc from java.util.function.Supplier.get.

Gets a result.

Returns:ExecutorService

a result

Annotations
@Override
invokeAllback to summary
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException

Implements java.util.concurrent.ExecutorService.invokeAll.

Doc from java.util.concurrent.ExecutorService.invokeAll.

Executes the given tasks, returning a list of Futures holding their status and results when all complete. Future#isDone is true for each element of the returned list. Note that a completed task could have terminated either normally or by throwing an exception. The results of this method are undefined if the given collection is modified while this operation is in progress.

Parameters
<T>
the type of the values returned from the tasks
tasks:Collection<? extends Callable<T>>

the collection of tasks

Returns:List<Future<T>>

a list of Futures representing the tasks, in the same sequential order as produced by the iterator for the given task list, each of which has completed

Annotations
@NonNull
@Override
Exceptions
InterruptedException:
if interrupted while waiting, in which case unfinished tasks are cancelled
invokeAllback to summary
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException

Implements java.util.concurrent.ExecutorService.invokeAll.

Doc from java.util.concurrent.ExecutorService.invokeAll.

Executes the given tasks, returning a list of Futures holding their status and results when all complete or the timeout expires, whichever happens first. Future#isDone is true for each element of the returned list. Upon return, tasks that have not completed are cancelled. Note that a completed task could have terminated either normally or by throwing an exception. The results of this method are undefined if the given collection is modified while this operation is in progress.

Parameters
<T>
the type of the values returned from the tasks
tasks:Collection<? extends Callable<T>>

the collection of tasks

timeout:long

the maximum time to wait

unit:TimeUnit

the time unit of the timeout argument

Returns:List<Future<T>>

a list of Futures representing the tasks, in the same sequential order as produced by the iterator for the given task list. If the operation did not time out, each task will have completed. If it did time out, some of these tasks will not have completed.

Annotations
@NonNull
@Override
Exceptions
InterruptedException:
if interrupted while waiting, in which case unfinished tasks are cancelled
invokeAnyback to summary
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException

Implements java.util.concurrent.ExecutorService.invokeAny.

Doc from java.util.concurrent.ExecutorService.invokeAny.

Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do. Upon normal or exceptional return, tasks that have not completed are cancelled. The results of this method are undefined if the given collection is modified while this operation is in progress.

Parameters
<T>
the type of the values returned from the tasks
tasks:Collection<? extends Callable<T>>

the collection of tasks

Returns:T

the result returned by one of the tasks

Annotations
@NonNull
@Override
Exceptions
InterruptedException:
if interrupted while waiting
ExecutionException:
if no task successfully completes
invokeAnyback to summary
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException

Implements java.util.concurrent.ExecutorService.invokeAny.

Doc from java.util.concurrent.ExecutorService.invokeAny.

Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do before the given timeout elapses. Upon normal or exceptional return, tasks that have not completed are cancelled. The results of this method are undefined if the given collection is modified while this operation is in progress.

Parameters
<T>
the type of the values returned from the tasks
tasks:Collection<? extends Callable<T>>

the collection of tasks

timeout:long

the maximum time to wait

unit:TimeUnit

the time unit of the timeout argument

Returns:T

the result returned by one of the tasks

Annotations
@Override
Exceptions
InterruptedException:
if interrupted while waiting
ExecutionException:
if no task successfully completes
TimeoutException:
if the given timeout elapses before any task successfully completes
isShutdownback to summary
public boolean isShutdown()

Implements java.util.concurrent.ExecutorService.isShutdown.

Doc from java.util.concurrent.ExecutorService.isShutdown.

Returns true if this executor has been shut down.

Returns:boolean

true if this executor has been shut down

Annotations
@Override
isTerminatedback to summary
public boolean isTerminated()

Implements java.util.concurrent.ExecutorService.isTerminated.

Doc from java.util.concurrent.ExecutorService.isTerminated.

Returns true if all tasks have completed following shut down. Note that isTerminated is never true unless either shutdown or shutdownNow was called first.

Returns:boolean

true if all tasks have completed following shut down

Annotations
@Override
scheduleback to summary
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)

Implements 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:ScheduledFuture<?>

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

Annotations
@NonNull
@Override
scheduleback to summary
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit)

Implements 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:ScheduledFuture<V>

a ScheduledFuture that can be used to extract result or cancel

Annotations
@NonNull
@Override
scheduleAtFixedRateback to summary
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)

Implements 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:ScheduledFuture<?>

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
@NonNull
@Override
scheduleWithFixedDelayback to summary
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)

Implements 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:ScheduledFuture<?>

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
@NonNull
@Override
shutdownback to summary
public void shutdown()

Implements java.util.concurrent.ExecutorService.shutdown.

Doc from java.util.concurrent.ExecutorService.shutdown.

Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down.

This method does not wait for previously submitted tasks to complete execution. Use awaitTermination to do that.

Annotations
@Override
shutdownNowback to summary
public List<Runnable> shutdownNow()

Implements java.util.concurrent.ExecutorService.shutdownNow.

Doc from java.util.concurrent.ExecutorService.shutdownNow.

Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution.

This method does not wait for actively executing tasks to terminate. Use awaitTermination to do that.

There are no guarantees beyond best-effort attempts to stop processing actively executing tasks. For example, typical implementations will cancel via Thread#interrupt, so any task that fails to respond to interrupts may never terminate.

Returns:List<Runnable>

list of tasks that never commenced execution

Annotations
@NonNull
@Override
submitback to summary
public <T> Future<T> submit(Callable<T> task)

Implements java.util.concurrent.ExecutorService.submit.

Doc from java.util.concurrent.ExecutorService.submit.

Submits a value-returning task for execution and returns a Future representing the pending results of the task. The Future's get method will return the task's result upon successful completion.

If you would like to immediately block waiting for a task, you can use constructions of the form result = exec.submit(aCallable).get();

Note

The Executors class includes a set of methods that can convert some other common closure-like objects, for example, java.security.PrivilegedAction to Callable form so they can be submitted.

Parameters
<T>
the type of the task's result
task:Callable<T>

the task to submit

Returns:Future<T>

a Future representing pending completion of the task

Annotations
@NonNull
@Override
submitback to summary
public <T> Future<T> submit(Runnable task, T result)

Implements java.util.concurrent.ExecutorService.submit.

Doc from java.util.concurrent.ExecutorService.submit.

Submits a Runnable task for execution and returns a Future representing that task. The Future's get method will return the given result upon successful completion.

Parameters
<T>
the type of the result
task:Runnable

the task to submit

result:T

the result to return

Returns:Future<T>

a Future representing pending completion of the task

Annotations
@NonNull
@Override
submitback to summary
public Future<?> submit(Runnable task)

Implements java.util.concurrent.ExecutorService.submit.

Doc from java.util.concurrent.ExecutorService.submit.

Submits a Runnable task for execution and returns a Future representing that task. The Future's get method will return null upon successful completion.

Parameters
task:Runnable

the task to submit

Returns:Future<?>

a Future representing pending completion of the task

Annotations
@NonNull
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override