Class ThreadPoolUtils
java.lang.Object
org.apache.qpid.protonj2.client.util.ThreadPoolUtils
Utility methods for working with thread pools 
ExecutorService.- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final longDefault thread pool shutdown timeout used to await graceful shutdown.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic booleanawaitTermination(ExecutorService executorService, long shutdownAwaitTermination) Awaits the termination of the thread pool.static voidshutdown(ExecutorService executorService) Shutdown the given executor service only (ie not graceful shutdown).static voidshutdownGraceful(ExecutorService executorService) Shutdown the given executor service graceful at first, and then aggressively if the await termination timeout was hit.static voidshutdownGraceful(ExecutorService executorService, long shutdownAwaitTermination) Shutdown the given executor service graceful at first, and then aggressively if the await termination timeout was hit.shutdownNow(ExecutorService executorService) Shutdown now the given executor service aggressively.
- 
Field Details- 
DEFAULT_SHUTDOWN_AWAIT_TERMINATIONpublic static final long DEFAULT_SHUTDOWN_AWAIT_TERMINATIONDefault thread pool shutdown timeout used to await graceful shutdown.- See Also:
 
 
- 
- 
Constructor Details- 
ThreadPoolUtilspublic ThreadPoolUtils()
 
- 
- 
Method Details- 
shutdownShutdown the given executor service only (ie not graceful shutdown).- Parameters:
- executorService- The ExecutorService that is being shutdown.
- See Also:
 
- 
shutdownNowShutdown now the given executor service aggressively.- Parameters:
- executorService- the executor service to shutdown now
- Returns:
- list of tasks that never commenced execution
- See Also:
 
- 
shutdownGracefulShutdown the given executor service graceful at first, and then aggressively if the await termination timeout was hit.This implementation invokes the shutdownGraceful(java.util.concurrent.ExecutorService, long)with a timeout value ofDEFAULT_SHUTDOWN_AWAIT_TERMINATIONmillis.- Parameters:
- executorService- The ExecutorService that is being shutdown.
 
- 
shutdownGracefulShutdown the given executor service graceful at first, and then aggressively if the await termination timeout was hit.Will try to perform an orderly shutdown by giving the running threads time to complete tasks, before going more aggressively by doing a shutdownNow(java.util.concurrent.ExecutorService)which forces a shutdown. The parametershutdownAwaitTerminationis used as timeout value waiting for orderly shutdown to complete normally, before going aggressively.- Parameters:
- executorService- the executor service to shutdown
- shutdownAwaitTermination- timeout in millis to wait for orderly shutdown
 
- 
awaitTerminationpublic static boolean awaitTermination(ExecutorService executorService, long shutdownAwaitTermination) throws InterruptedException Awaits the termination of the thread pool.This implementation will log every 2nd second at INFO level that we are waiting, so the end user can see we are not hanging in case it takes longer time to terminate the pool. - Parameters:
- executorService- the thread pool
- shutdownAwaitTermination- time in millis to use as timeout
- Returns:
- trueif the pool is terminated, or- falseif we timed out
- Throws:
- InterruptedException- is thrown if we are interrupted during the waiting
 
 
-