@Deprecated
public final class ThreadDeathWatcher
extends java.lang.Object
This thread starts a daemon thread to check the state of the threads being watched and to invoke their
associated Runnable
s. 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.
限定符和类型 | 方法和说明 |
---|---|
static boolean |
awaitInactivity(long timeout,
java.util.concurrent.TimeUnit unit)
已过时。
Waits until the thread of this watcher has no threads to watch and terminates itself.
|
static void |
unwatch(java.lang.Thread thread,
java.lang.Runnable task)
已过时。
Cancels the task scheduled via
watch(Thread, Runnable) . |
static void |
watch(java.lang.Thread thread,
java.lang.Runnable task)
已过时。
Schedules the specified
task to run when the specified thread dies. |
public static void watch(java.lang.Thread thread, java.lang.Runnable task)
task
to run when the specified thread
dies.thread
- the Thread
to watchtask
- the Runnable
to run when the thread
diesjava.lang.IllegalArgumentException
- if the specified thread
is not alivepublic static void unwatch(java.lang.Thread thread, java.lang.Runnable task)
watch(Thread, Runnable)
.public static boolean awaitInactivity(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
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.true
if and only if the watcher thread has been terminatedjava.lang.InterruptedException