ShutdownThreadsHelper (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.util, class: ShutdownThreadsHelper

Package org.apache.hadoop.util

# Class ShutdownThreadsHelper

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

public class ShutdownThreadsHelper extends Object
Helper class to shutdown `Thread`s and `ExecutorService`s.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ShutdownThreadsHelper()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static boolean`
  `shutdownExecutorService(ExecutorService service)`
  shutdownExecutorService.
  `static boolean`
  `shutdownExecutorService(ExecutorService service, long timeoutInMs)`
  shutdownExecutorService.
  `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 Details

  - ### ShutdownThreadsHelper

    public ShutdownThreadsHelper()

- ## Method Details

  - ### shutdownThread

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

  - ### 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

  - ### shutdownExecutorService

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

  - ### shutdownExecutorService

    public static boolean shutdownExecutorService(ExecutorService service, long timeoutInMs) throws InterruptedException
    shutdownExecutorService.
    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` - if the thread is interrupted.