Class ActivityWatchdog
- java.lang.Object
-
- java.lang.Thread
-
- net.timewalker.ffmq4.utils.watchdog.ActivityWatchdog
-
- All Implemented Interfaces:
Runnable
public class ActivityWatchdog extends Thread
Daemon thread watching a list of active objects.
The watchdog will wake up every WAKE_UP_INTERVAL milliseconds and check the active objects last activity timestamps. If an active object has been inactive for too long, its associated timeout callback is called.
The activity watchdog is a singleton.
- See Also:
ActiveObject
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
-
Field Summary
-
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ActivityWatchdoggetInstance()Get the singleton instancevoidpleaseStop()Ask the watchdog thread to stopvoidregister(ActiveObject object)Register an active object to be monitoredvoidrun()voidunregister(ActiveObject object)Unregister a monitored active object-
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 Detail
-
getInstance
public static ActivityWatchdog getInstance()
Get the singleton instance- Returns:
- the singleton instance
-
pleaseStop
public void pleaseStop()
Ask the watchdog thread to stop
-
register
public void register(ActiveObject object)
Register an active object to be monitored- Parameters:
object- the object to register
-
unregister
public void unregister(ActiveObject object)
Unregister a monitored active object- Parameters:
object- the object to unregister
-
-