-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classWatchdog.HandlerCheckerUsed for checking status of handle threads and scheduling monitor callbacks.
public interfaceWatchdog.Monitor
-
Field Summary
Fields Modifier and Type Field Description public final static booleanDEBUG
-
Method Summary
Modifier and Type Method Description static WatchdoggetInstance()voidaddThread(Handler thread)voidaddThread(Handler thread, long timeoutMillis)voidremoveThread(Handler thread)voidpauseWatchingCurrentThread(String reason)Pauses Watchdog action for the currently running thread. voidresumeWatchingCurrentThread(String reason)Resumes the last pause from pauseWatchingCurrentThread for the currently runningthread. voidrun()-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, onSpinWait, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, start, stop, suspend, toString, yield -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getInstance
static Watchdog getInstance()
-
addThread
void addThread(Handler thread)
-
addThread
void addThread(Handler thread, long timeoutMillis)
-
removeThread
void removeThread(Handler thread)
-
pauseWatchingCurrentThread
void pauseWatchingCurrentThread(String reason)
Pauses Watchdog action for the currently running thread. Useful before executing long runningoperations that could falsely trigger the watchdog. Each call to this will require a matchingcall to resumeWatchingCurrentThread.
If the current thread has not been added to the Watchdog, this call is a no-op.
If the Watchdog is already paused for the current thread, this call addsadds another pause and will require an additional resumeCurrentThread to resume.
Note: Use with care, as any deadlocks on the current thread will be undetected until allpauses have been resumed.
-
resumeWatchingCurrentThread
void resumeWatchingCurrentThread(String reason)
Resumes the last pause from pauseWatchingCurrentThread for the currently runningthread.
If the current thread has not been added to the Watchdog, this call is a no-op.
If the Watchdog action for the current thread is already resumed, this call logs a wtf.
If all pauses have been resumed, the Watchdog action is finally resumed, otherwise,the Watchdog action for the current thread remains paused until resume is called at leastas many times as the calls to pause.
-
run
void run()
-
-
-
-