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 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.executorService
- the executor service to shutdownshutdownAwaitTermination
- timeout in millis to wait for orderly shutdownpublic 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 The Apache Software Foundation. All rights reserved.