Package io.netty.util

Class ThreadDeathWatcher


  • @Deprecated
    public final class ThreadDeathWatcher
    extends Object
    Deprecated.
    will be removed in the next major release
    Checks if a thread is alive periodically and runs a task when a thread dies.

    This thread starts a daemon thread to check the state of the threads being watched and to invoke their associated Runnables. When there is no thread to watch (i.e. all threads are dead), the daemon thread will terminate itself, and a new daemon thread will be started again when a new watch is added.

    • Method Detail

      • watch

        public static void watch​(Thread thread,
                                 Runnable task)
        Deprecated.
        Schedules the specified task to run when the specified thread dies.
        Parameters:
        thread - the Thread to watch
        task - the Runnable to run when the thread dies
        Throws:
        IllegalArgumentException - if the specified thread is not alive
      • awaitInactivity

        public static boolean awaitInactivity​(long timeout,
                                              TimeUnit unit)
                                       throws InterruptedException
        Deprecated.
        Waits until the thread of this watcher has no threads to watch and terminates itself. Because a new watcher thread will be started again on watch(Thread, Runnable), this operation is only useful when you want to ensure that the watcher thread is terminated after your application is shut down and there's no chance of calling watch(Thread, Runnable) afterwards.
        Returns:
        true if and only if the watcher thread has been terminated
        Throws:
        InterruptedException