public abstract class ShutdownableThread extends Thread
Thread.State, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
String |
logPrefix |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
ShutdownableThread(String name) |
ShutdownableThread(String name,
boolean isInterruptible) |
ShutdownableThread(String name,
boolean isInterruptible,
String logPrefix) |
Modifier and Type | Method and Description |
---|---|
void |
awaitShutdown()
After calling initiateShutdown(), use this API to wait until the shutdown is complete.
|
abstract void |
doWork()
This method is repeatedly invoked until the thread shuts down or this method throws an exception
|
void |
heartbeat() |
boolean |
initiateShutdown() |
boolean |
isRunning() |
boolean |
isShutdownComplete() |
boolean |
isShutdownInitiated() |
boolean |
isThreadFailed() |
void |
pause(long timeout,
TimeUnit unit)
Causes the current thread to wait until the shutdown is initiated,
or the specified waiting time elapses.
|
void |
run() |
void |
shutdown() |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public final String logPrefix
public ShutdownableThread(String name)
public ShutdownableThread(String name, boolean isInterruptible)
public void shutdown() throws InterruptedException
InterruptedException
public boolean isShutdownInitiated()
public boolean isShutdownComplete()
public boolean isThreadFailed()
public boolean initiateShutdown()
public void awaitShutdown() throws InterruptedException
InterruptedException
public void pause(long timeout, TimeUnit unit) throws InterruptedException
timeout
- wait time in units.unit
- TimeUnit value for the wait time.InterruptedException
public void heartbeat()
public abstract void doWork()
public boolean isRunning()