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 and Description
    `ShutdownThreadsHelper()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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 © 2008–2022 Apache Software Foundation. All rights reserved.