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

    Nested classes/interfaces inherited from class java.lang.Thread

    java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
  • Field Summary

    Fields inherited from class java.lang.Thread

    MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
  • 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 it
    static 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

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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 interface java.lang.Runnable
      Overrides:
      run in class java.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 the ExtendedServlet 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 -