Class ExecutorCloser
java.lang.Object
org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser
- All Implemented Interfaces:
Closeable,AutoCloseable
Utility class to properly close any ExecutorService.
It will attempt a graceful close within the provided timeout. If after such any of the contained tasks are not terminated yet, it will force a shutdown and track a warning in the logs.
-
Constructor Summary
ConstructorsConstructorDescriptionExecutorCloser(@Nullable ExecutorService executorService) will attempt a graceful close in 5 secondsExecutorCloser(@Nullable ExecutorService executorService, int timeout, TimeUnit unit) will attempt a graceful close by the provided time. -
Method Summary
-
Constructor Details
-
ExecutorCloser
will attempt a graceful close in 5 seconds- Parameters:
executorService-
-
ExecutorCloser
public ExecutorCloser(@Nullable @Nullable ExecutorService executorService, int timeout, TimeUnit unit) will attempt a graceful close by the provided time.- Parameters:
executorService- the executor to closetimeout- the time to wait forunit- the unit of time
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-