Package org.apache.curator.utils
Class CloseableScheduledExecutorService
- java.lang.Object
-
- org.apache.curator.utils.CloseableExecutorService
-
- org.apache.curator.utils.CloseableScheduledExecutorService
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class CloseableScheduledExecutorService extends CloseableExecutorService
Decoration on an ScheduledExecutorService that tracks created futures and provides a method to close futures created via this class
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.curator.utils.CloseableExecutorService
CloseableExecutorService.InternalFutureTask<T>, CloseableExecutorService.InternalScheduledFutureTask
-
-
Field Summary
-
Fields inherited from class org.apache.curator.utils.CloseableExecutorService
isOpen
-
-
Constructor Summary
Constructors Constructor Description CloseableScheduledExecutorService(java.util.concurrent.ScheduledExecutorService scheduledExecutorService)CloseableScheduledExecutorService(java.util.concurrent.ScheduledExecutorService scheduledExecutorService, boolean shutdownOnClose)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.Future<?>schedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)Creates and executes a one-shot action that becomes enabled after the given delay.java.util.concurrent.Future<?>scheduleWithFixedDelay(java.lang.Runnable task, long initialDelay, long delay, java.util.concurrent.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.-
Methods inherited from class org.apache.curator.utils.CloseableExecutorService
close, isShutdown, submit, submit
-
-
-
-
Constructor Detail
-
CloseableScheduledExecutorService
public CloseableScheduledExecutorService(java.util.concurrent.ScheduledExecutorService scheduledExecutorService)
- Parameters:
scheduledExecutorService- the service to decorate
-
CloseableScheduledExecutorService
public CloseableScheduledExecutorService(java.util.concurrent.ScheduledExecutorService scheduledExecutorService, boolean shutdownOnClose)- Parameters:
scheduledExecutorService- the service to decorateshutdownOnClose- if true, shutdown the executor service when this is closed
-
-
Method Detail
-
schedule
public java.util.concurrent.Future<?> schedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)Creates and executes a one-shot action that becomes enabled after the given delay.- Parameters:
task- the task to executedelay- the time from now to delay executionunit- the time unit of the delay parameter- Returns:
- a Future representing pending completion of the task and whose get() method will return null upon completion
-
scheduleWithFixedDelay
public java.util.concurrent.Future<?> scheduleWithFixedDelay(java.lang.Runnable task, long initialDelay, long delay, java.util.concurrent.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. 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.- Parameters:
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 parameters- Returns:
- a Future representing pending completion of the task, and whose get() method will throw an exception upon cancellation
-
-