|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectThreadWatcher
public class ThreadWatcher
Keeps an eye on threads, and logs those that appear to be "runaways".
Nested Class Summary | |
---|---|
private static class |
ThreadWatcher.Entry
Keeps track of one thread we're watching. |
Field Summary | |
---|---|
private static HashMap |
beingWatched
|
private static Thread |
watcherThread
|
Constructor Summary | |
---|---|
ThreadWatcher()
|
Method Summary | |
---|---|
static void |
beginWatch(String descrip,
long normalTime,
long killTime)
Notifies the watcher that the current thread is about to begin an operation that might turn into a runaway. |
static void |
endWatch()
Notifies the watcher that the current thread has completed the operation begun after beginWatch(String,long,long) . |
static int |
nRunaways()
Counts the number of runaway threads at the moment. |
static boolean |
shouldDie(Thread thread)
Tells whether the specified thread has exceeded its kill limit and should kill itself off. |
private static void |
watch()
This is the worker function that runs in a separate thread and keeps an eye out for runaways. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static HashMap beingWatched
private static Thread watcherThread
Constructor Detail |
---|
public ThreadWatcher()
Method Detail |
---|
public static void beginWatch(String descrip, long normalTime, long killTime)
endWatch()
when it completes the operation.
descrip
- Description of the operation being started, used
for log messages.normalTime
- Max number of milliseconds the operation is expected
to take, after which warnings will be printed
about the thread being "runaway."killTime
- Number of milliseconds after which the thread should
be killed (by setting a flag that hopefully it will
check.)public static void endWatch()
beginWatch(String,long,long)
.
public static int nRunaways()
public static boolean shouldDie(Thread thread)
private static void watch()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |