public class CloseableScheduledExecutorService extends CloseableExecutorService
CloseableExecutorService.InternalFutureTask<T>, CloseableExecutorService.InternalScheduledFutureTaskisOpen| Constructor and Description |
|---|
CloseableScheduledExecutorService(ScheduledExecutorService scheduledExecutorService) |
CloseableScheduledExecutorService(ScheduledExecutorService scheduledExecutorService,
boolean shutdownOnClose) |
| Modifier and Type | Method and Description |
|---|---|
Future<?> |
schedule(Runnable task,
long delay,
TimeUnit unit)
Creates and executes a one-shot action that becomes enabled
after the given delay.
|
Future<?> |
scheduleAtFixedRate(Runnable task,
long initialDelay,
long period,
TimeUnit unit)
Creates and executes 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. |
Future<?> |
scheduleWithFixedDelay(Runnable task,
long initialDelay,
long delay,
TimeUnit unit)
Creates and executes 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.
|
close, isShutdown, submit, submitpublic CloseableScheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
scheduledExecutorService - the service to decoratepublic CloseableScheduledExecutorService(ScheduledExecutorService scheduledExecutorService, boolean shutdownOnClose)
scheduledExecutorService - the service to decorateshutdownOnClose - if true, shutdown the executor service when this is closedpublic Future<?> schedule(Runnable task, long delay, TimeUnit unit)
task - the task to executedelay - the time from now to delay executionunit - the time unit of the delay parameterpublic Future<?> scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit)
task - 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 parameterspublic Future<?> scheduleAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)
initialDelay then initialDelay+period, then initialDelay + 2 * period, and so
on. If any execution of the task encounters an exception, subsequent executions are suppressed.
Otherwise, the task will only terminate via cancellation or termination of the executor. If any
execution of this task takes longer than its period, then subsequent executions may start late,
but will not concurrently execute.task - the task to executeinitialDelay - the time to delay first executionperiod - the period between successive executionsunit - the time unit of the initialDelay and delay parametersCopyright © 2011–2023 The Apache Software Foundation. All rights reserved.