Class ExecutorCloser
- java.lang.Object
-
- org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public final class ExecutorCloser extends java.lang.Object implements java.io.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 java.util.concurrent.ExecutorService executorService)
will attempt a graceful close in 5 secondsExecutorCloser(@Nullable java.util.concurrent.ExecutorService executorService, int timeout, java.util.concurrent.TimeUnit unit)
will attempt a graceful close by the provided time.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
-
-
-
Constructor Detail
-
ExecutorCloser
public ExecutorCloser(@Nullable @Nullable java.util.concurrent.ExecutorService executorService)
will attempt a graceful close in 5 seconds- Parameters:
executorService
-
-
ExecutorCloser
public ExecutorCloser(@Nullable @Nullable java.util.concurrent.ExecutorService executorService, int timeout, java.util.concurrent.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
-
-