Package io.netty.util
Class ThreadDeathWatcher
- java.lang.Object
-
- io.netty.util.ThreadDeathWatcher
-
@Deprecated public final class ThreadDeathWatcher extends java.lang.ObjectDeprecated.will be removed in the next major releaseChecks 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 Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static booleanawaitInactivity(long timeout, java.util.concurrent.TimeUnit unit)Deprecated.Waits until the thread of this watcher has no threads to watch and terminates itself.static voidunwatch(java.lang.Thread thread, java.lang.Runnable task)Deprecated.Cancels the task scheduled viawatch(Thread, Runnable).static voidwatch(java.lang.Thread thread, java.lang.Runnable task)Deprecated.Schedules the specifiedtaskto run when the specifiedthreaddies.
-
-
-
Method Detail
-
watch
public static void watch(java.lang.Thread thread, java.lang.Runnable task)Deprecated.Schedules the specifiedtaskto run when the specifiedthreaddies.- Parameters:
thread- theThreadto watchtask- theRunnableto run when thethreaddies- Throws:
java.lang.IllegalArgumentException- if the specifiedthreadis not alive
-
unwatch
public static void unwatch(java.lang.Thread thread, java.lang.Runnable task)Deprecated.Cancels the task scheduled viawatch(Thread, Runnable).
-
awaitInactivity
public static boolean awaitInactivity(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedExceptionDeprecated.Waits until the thread of this watcher has no threads to watch and terminates itself. Because a new watcher thread will be started again onwatch(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 callingwatch(Thread, Runnable)afterwards.- Returns:
trueif and only if the watcher thread has been terminated- Throws:
java.lang.InterruptedException
-
-