Package org.apache.curator.utils
Class CloseableExecutorService
java.lang.Object
org.apache.curator.utils.CloseableExecutorService
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
CloseableScheduledExecutorService
Decoration on an ExecutorService that tracks created futures and provides
a method to close futures created via this class
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classprotected class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCloseableExecutorService(ExecutorService executorService) CloseableExecutorService(ExecutorService executorService, boolean shutdownOnClose) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes any tasks currently in progressbooleanReturns true if this executor has been shut down.Future<?> Submits a Runnable task for execution and returns a Future representing that task.<V> Future<V> Submits a value-returning task for execution and returns a Future representing the pending results of the task.
-
Field Details
-
isOpen
-
-
Constructor Details
-
CloseableExecutorService
- Parameters:
executorService- the service to decorate
-
CloseableExecutorService
- Parameters:
executorService- the service to decorateshutdownOnClose- if true, shutdown the executor service when this is closed
-
-
Method Details
-
isShutdown
public boolean isShutdown()Returns true if this executor has been shut down.- Returns:
- true if this executor has been shut down
-
close
public void close()Closes any tasks currently in progress- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
submit
Submits a value-returning task for execution and returns a Future representing the pending results of the task. Upon completion, this task may be taken or polled.- Parameters:
task- the task to submit- Returns:
- a future to watch the task
-
submit
Submits a Runnable task for execution and returns a Future representing that task. Upon completion, this task may be taken or polled.- Parameters:
task- the task to submit- Returns:
- a future to watch the task
-