Class AutopsyThread

  • All Implemented Interfaces:
    java.lang.Runnable

    public class AutopsyThread
    extends java.lang.Thread
    This thread is able to capture uncaught exceptions from run() so other classes can check the status of the thread and know why it crashed.
    • 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
    • Constructor Summary

      Constructors 
      Constructor Description
      AutopsyThread()
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean crashed()
      Checks if the thread has crashed.
      java.lang.Throwable getError()
      Gets the crashing error.
      void onError​(java.lang.Throwable t)
      Handles the uncaught error on thread crashing.
      void setError​(java.lang.Throwable t)
      Sets the error before exiting.
      • 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, run, 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
    • Constructor Detail

      • AutopsyThread

        public AutopsyThread()
        Constructor.
    • Method Detail

      • crashed

        public boolean crashed()
        Checks if the thread has crashed.
        Returns:
        true if the thread crashed due to an uncaught exception
      • setError

        public void setError​(java.lang.Throwable t)
        Sets the error before exiting.
        Parameters:
        t - the crashing error
      • onError

        public void onError​(java.lang.Throwable t)
        Handles the uncaught error on thread crashing. By default, just log the error for further analysis.
        Parameters:
        t - the crashing error
      • getError

        @Nullable
        public java.lang.Throwable getError()
        Gets the crashing error.
        Returns:
        the error