Package 

Class Watchdog

  • All Implemented Interfaces:
    java.lang.Runnable

    
    public class Watchdog
    extends Thread
                        
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public final class Watchdog.HandlerChecker

      Used for checking status of handle threads and scheduling monitor callbacks.

      public interface Watchdog.Monitor
    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static boolean DEBUG
    • Method Summary

      Modifier and Type Method Description
      static Watchdog getInstance()
      void addThread(Handler thread)
      void addThread(Handler thread, long timeoutMillis)
      void removeThread(Handler thread)
      void pauseWatchingCurrentThread(String reason) Pauses Watchdog action for the currently running thread.
      void resumeWatchingCurrentThread(String reason) Resumes the last pause from pauseWatchingCurrentThread for the currently runningthread.
      void run()
      • 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

      • addThread

         void addThread(Handler thread, long timeoutMillis)
      • 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()