org.apache.hadoop.util
Class ShutdownThreadsHelper

java.lang.Object
  extended by org.apache.hadoop.util.ShutdownThreadsHelper

public class ShutdownThreadsHelper
extends Object

Helper class to shutdown Threads and ExecutorServices.


Constructor Summary
ShutdownThreadsHelper()
           
 
Method Summary
static boolean shutdownExecutorService(ExecutorService service)
           
static boolean shutdownExecutorService(ExecutorService service, long timeoutInMs)
           
static boolean shutdownThread(Thread thread)
           
static boolean shutdownThread(Thread thread, long timeoutInMilliSeconds)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShutdownThreadsHelper

public ShutdownThreadsHelper()
Method Detail

shutdownThread

public static boolean shutdownThread(Thread thread)
Parameters:
thread - to be shutdown
Returns:
true if the thread is successfully interrupted, false otherwise
Throws:
InterruptedException

shutdownThread

public static boolean shutdownThread(Thread thread,
                                     long timeoutInMilliSeconds)
Parameters:
thread - to be shutdown
timeoutInMilliSeconds - time to wait for thread to join after being interrupted
Returns:
true if the thread is successfully interrupted, false otherwise
Throws:
InterruptedException

shutdownExecutorService

public static boolean shutdownExecutorService(ExecutorService service)
                                       throws InterruptedException
Parameters:
service - to be shutdown
Returns:
true if the service is terminated, false otherwise
Throws:
InterruptedException

shutdownExecutorService

public static boolean shutdownExecutorService(ExecutorService service,
                                              long timeoutInMs)
                                       throws InterruptedException
Parameters:
service - to be shutdown
timeoutInMs - time to wait for ExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit) calls in milli seconds.
Returns:
true if the service is terminated, false otherwise
Throws:
InterruptedException


Copyright © 2014 Apache Software Foundation. All Rights Reserved.