public final class ThreadPoolUtils extends Object
ExecutorService
.Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_SHUTDOWN_AWAIT_TERMINATION |
Constructor and Description |
---|
ThreadPoolUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
awaitTermination(ExecutorService executorService)
Awaits the termination of the thread pool indefinitely (Use with Caution).
|
static boolean |
awaitTermination(ExecutorService executorService,
long shutdownAwaitTermination)
Awaits the termination of the thread pool.
|
static void |
shutdown(ExecutorService executorService)
Shutdown the given executor service only (ie not graceful shutdown).
|
static void |
shutdownGraceful(ExecutorService executorService)
Shutdown the given executor service graceful at first, and then aggressively
if the await termination timeout was hit.
|
static void |
shutdownGraceful(ExecutorService executorService,
long shutdownAwaitTermination)
Shutdown the given executor service graceful at first, and then aggressively
if the await termination timeout was hit.
|
static List<Runnable> |
shutdownNow(ExecutorService executorService)
Shutdown now the given executor service aggressively.
|
public static final long DEFAULT_SHUTDOWN_AWAIT_TERMINATION
public ThreadPoolUtils()
public static void shutdown(ExecutorService executorService)
ExecutorService.shutdown()
public static List<Runnable> shutdownNow(ExecutorService executorService)
executorService
- the executor service to shutdown nowExecutorService.shutdownNow()
public static void shutdownGraceful(ExecutorService executorService)
shutdownGraceful(java.util.concurrent.ExecutorService, long)
with a timeout value of DEFAULT_SHUTDOWN_AWAIT_TERMINATION
millis.public static void shutdownGraceful(ExecutorService executorService, long shutdownAwaitTermination)
shutdownNow(java.util.concurrent.ExecutorService)
which
forces a shutdown. The parameter shutdownAwaitTermination
is used as timeout value waiting for orderly shutdown to
complete normally, before going aggressively. If the shutdownAwaitTermination
value is negative the shutdown waits indefinitely for the ExecutorService
to complete its shutdown.executorService
- the executor service to shutdownshutdownAwaitTermination
- timeout in millis to wait for orderly shutdownpublic static void awaitTermination(ExecutorService executorService) throws InterruptedException
executorService
- the thread poolInterruptedException
- is thrown if we are interrupted during the waitingpublic static boolean awaitTermination(ExecutorService executorService, long shutdownAwaitTermination) throws InterruptedException
executorService
- the thread poolshutdownAwaitTermination
- time in millis to use as timeoutInterruptedException
- is thrown if we are interrupted during the waitingCopyright © 2005–2016 FuseSource, Corp.. All rights reserved.