Package lazyj
Class ThreadsMonitor
java.lang.Object
java.lang.Thread
lazyj.ThreadsMonitor
- All Implemented Interfaces:
java.lang.Runnable
public final class ThreadsMonitor
extends java.lang.Thread
This class is used to monitor servlet threads, killing the ones that run for longer than it was specified. See
ExtendedServlet.getMaxRunTime()
for more information on how to modify
the maximum run time for a servlet.- Since:
- 2006-10-04
- Author:
- costing
-
Nested Class Summary
-
Field Summary
-
Method Summary
Modifier and Type Method Description static void
register(lazyj.BoundedThreadContainer btc)
Register a thread that must be allowed to run but for a limited amount of time.void
run()
The monitoring thread, takes the next thread (servlet) that ran for longer than expected and kills itstatic void
unregister(lazyj.BoundedThreadContainer btc)
Remove a previously added wrapper.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Method Details
-
run
public void run()The monitoring thread, takes the next thread (servlet) that ran for longer than expected and kills it- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-
register
public static void register(lazyj.BoundedThreadContainer btc)Register a thread that must be allowed to run but for a limited amount of time. This is used by theExtendedServlet
wrapper to keep under control the servlets, but you could use it for any other thread.- Parameters:
btc
- the wrapper for the thread to be monitored
-
unregister
public static void unregister(lazyj.BoundedThreadContainer btc)Remove a previously added wrapper. Use this when the thread correctly finishes the work. You should explicitly call this when the work is done because otherwise you will probably kill something else that could be running later under that thread, and you don't want this, right? :)- Parameters:
btc
-
-