Package alluxio.thread
Class AutopsyThread
- java.lang.Object
-
- java.lang.Thread
-
- alluxio.thread.AutopsyThread
-
- All Implemented Interfaces:
java.lang.Runnable
public class AutopsyThread extends java.lang.Thread
This thread is able to capture uncaught exceptions fromrun()
so other classes can check the status of the thread and know why it crashed.
-
-
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
-
-
-
-
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
-
-