public class GracefulExecutorServicesShutdown extends Object
shutdown(ExecutorService...)
method. The ExecutorService.shutdown() method is called immediately.
Calling the handle() method returns a future which completes when all executors
have been terminated.
The executors will waited for completion with the ExecutorService.awaitTermination(long, TimeUnit) method.
If the shutdown times out or the future is cancelled, all executors will be terminated and the termination
timeout value will be used for waiting for termination.
The default value for termination timeout is 10% of the shutdown timeout.| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Void> |
handle()
Starts the handler for polling frequently for the completed termination of enlisted executors.
|
static GracefulExecutorServicesShutdown |
initiate()
Initiates a new shutdown for one or many
ExecutorServices. |
GracefulExecutorServicesShutdown |
shutdown(ExecutorService... executorServices)
Calls
ExecutorService.shutdown() and enlists the executor as part of the
shutdown handling. |
GracefulExecutorServicesShutdown |
terminationTimeout(Duration terminationTimeout)
Sets the timeout for waiting for executors to complete in forceful termination.
|
GracefulExecutorServicesShutdown |
timeout(Duration timeout)
Sets the timeout for graceful shutdown.
|
public static GracefulExecutorServicesShutdown initiate()
ExecutorServices.public GracefulExecutorServicesShutdown shutdown(ExecutorService... executorServices)
ExecutorService.shutdown() and enlists the executor as part of the
shutdown handling.executorServices - one or many executors to shutdownpublic GracefulExecutorServicesShutdown timeout(Duration timeout)
timeout - duration for the timeoutpublic GracefulExecutorServicesShutdown terminationTimeout(Duration terminationTimeout)
terminationTimeout - duration for the timeoutpublic CompletableFuture<Void> handle()
ExecutorService.shutdownNow().Copyright © 2017–2022 Apache Software Foundation. All rights reserved.