Class ExecutorCloser
- java.lang.Object
-
- org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public final class ExecutorCloser extends Object implements Closeable
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
Constructors Constructor Description ExecutorCloser(@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.
-
-
-
Constructor Detail
-
ExecutorCloser
public ExecutorCloser(@Nullable @Nullable ExecutorService executorService)
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 Detail
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
-