Package org.apache.hadoop.util
Class ShutdownThreadsHelper
java.lang.Object
org.apache.hadoop.util.ShutdownThreadsHelper
Helper class to shutdown
Threads and ExecutorServices.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanshutdownExecutorService(ExecutorService service) shutdownExecutorService.static booleanshutdownExecutorService(ExecutorService service, long timeoutInMs) shutdownExecutorService.static booleanshutdownThread(Thread thread) static booleanshutdownThread(Thread thread, long timeoutInMilliSeconds)
-
Constructor Details
-
ShutdownThreadsHelper
public ShutdownThreadsHelper()
-
-
Method Details
-
shutdownThread
- Parameters:
thread-to be shutdown- Returns:
trueif the thread is successfully interrupted,falseotherwise
-
shutdownThread
- Parameters:
thread-to be shutdowntimeoutInMilliSeconds- time to wait for thread to join after being interrupted- Returns:
trueif the thread is successfully interrupted,falseotherwise
-
shutdownExecutorService
shutdownExecutorService.- Parameters:
service-to be shutdown- Returns:
trueif the service is terminated,falseotherwise- Throws:
InterruptedException- if the thread is interrupted.
-
shutdownExecutorService
public static boolean shutdownExecutorService(ExecutorService service, long timeoutInMs) throws InterruptedException shutdownExecutorService.- Parameters:
service-to be shutdowntimeoutInMs- time to wait forExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit)calls in milli seconds.- Returns:
trueif the service is terminated,falseotherwise- Throws:
InterruptedException- if the thread is interrupted.
-