public abstract class BackgroundThread extends Thread
Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
BackgroundThread(String name,
boolean daemon)
NEVER set daemon=true and override the cleanup() method.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
action()
The action taken by this background thread when the wait condition is met.
|
protected void |
cleanup()
Any clean up that needs to be done before this thread is closed down.
|
void |
close(Duration duration) |
void |
run() |
protected abstract void |
waitCondition()
The wait condition for the background thread.
|
activeCount, checkAccess, clone, 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 BackgroundThread(String name, boolean daemon)
name
- daemon
- protected abstract void waitCondition() throws InterruptedException
InterruptedException
protected abstract void action()
close(Duration)
.protected void cleanup()
public void close(Duration duration)
Copyright © 2012–2024. All rights reserved.