Class ThreadDeathWatcher

java.lang.Object
io.netty.util.ThreadDeathWatcher

@Deprecated public final class ThreadDeathWatcher extends java.lang.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.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static final class 
    Deprecated.
     
    private static final class 
    Deprecated.
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final InternalLogger
    Deprecated.
     
    private static final java.util.Queue<ThreadDeathWatcher.Entry>
    Deprecated.
     
    private static final java.util.concurrent.atomic.AtomicBoolean
    Deprecated.
     
    (package private) static final java.util.concurrent.ThreadFactory
    Deprecated.
     
    private static final ThreadDeathWatcher.Watcher
    Deprecated.
     
    private static java.lang.Thread
    Deprecated.
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Deprecated.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    awaitInactivity(long timeout, java.util.concurrent.TimeUnit unit)
    Deprecated.
    Waits until the thread of this watcher has no threads to watch and terminates itself.
    private static void
    schedule(java.lang.Thread thread, java.lang.Runnable task, boolean isWatch)
    Deprecated.
     
    static void
    unwatch(java.lang.Thread thread, java.lang.Runnable task)
    Deprecated.
    Cancels the task scheduled via watch(Thread, Runnable).
    static void
    watch(java.lang.Thread thread, java.lang.Runnable task)
    Deprecated.
    Schedules the specified task to run when the specified thread dies.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

      private static final InternalLogger logger
      Deprecated.
    • threadFactory

      static final java.util.concurrent.ThreadFactory threadFactory
      Deprecated.
    • pendingEntries

      private static final java.util.Queue<ThreadDeathWatcher.Entry> pendingEntries
      Deprecated.
    • watcher

      private static final ThreadDeathWatcher.Watcher watcher
      Deprecated.
    • started

      private static final java.util.concurrent.atomic.AtomicBoolean started
      Deprecated.
    • watcherThread

      private static volatile java.lang.Thread watcherThread
      Deprecated.
  • Constructor Details

    • ThreadDeathWatcher

      private ThreadDeathWatcher()
      Deprecated.
  • Method Details

    • watch

      public static void watch(java.lang.Thread thread, java.lang.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:
      java.lang.IllegalArgumentException - if the specified thread is not alive
    • unwatch

      public static void unwatch(java.lang.Thread thread, java.lang.Runnable task)
      Deprecated.
      Cancels the task scheduled via watch(Thread, Runnable).
    • schedule

      private static void schedule(java.lang.Thread thread, java.lang.Runnable task, boolean isWatch)
      Deprecated.
    • awaitInactivity

      public static boolean awaitInactivity(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.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:
      java.lang.InterruptedException