|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
de.unikassel.android.sdcframework.util.AbstractWorkerThread
public abstract class AbstractWorkerThread
Abstract base class for any thread in the SDC Framework.
Does provide the following features:
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private AtomicBoolean |
doLog
The logging state flag |
private AtomicBoolean |
hasTerminated
The terminated state flag |
private AtomicBoolean |
isNew
The new created state flag |
private AtomicBoolean |
isWorking
The isWorking state flag |
private Object |
syncLock
Synchronization lock |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
AbstractWorkerThread()
Constructor |
Method Summary | |
---|---|
protected abstract void |
doCleanUp()
The clean up method executed on termination |
private void |
doRun()
Does send the thread into running mode either by starting it if not alive or by waking a sleeping thread up. |
void |
doTerminate()
Does stop current work and trigger thread termination |
protected abstract void |
doWork()
The working method executed in the running loop if started |
boolean |
hasTerminated()
Getter for the terminated flag |
boolean |
isLogging()
Getter for the logging flag |
boolean |
isWorking()
Getter for the working flag |
protected void |
logMessage(String message)
Does log a message if logging is enabled |
void |
run()
|
void |
setLogging(boolean doLog)
Setter for the logging flag |
void |
start()
|
void |
startWork()
Does start working if thread is not in working state |
void |
stopWork()
Does stop working if thread is in working state |
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, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final AtomicBoolean isNew
private final AtomicBoolean hasTerminated
private final AtomicBoolean isWorking
private final AtomicBoolean doLog
private final Object syncLock
Constructor Detail |
---|
public AbstractWorkerThread()
Method Detail |
---|
public final boolean isWorking()
WorkerThread
isWorking
in interface WorkerThread
public final void setLogging(boolean doLog)
WorkerThread
setLogging
in interface WorkerThread
doLog
- flag if logging should be donepublic final boolean isLogging()
WorkerThread
isLogging
in interface WorkerThread
public final boolean hasTerminated()
WorkerThread
hasTerminated
in interface WorkerThread
public final void start()
start
in class Thread
public final void run()
run
in interface Runnable
run
in class Thread
public final void startWork()
WorkerThread
startWork
in interface WorkerThread
private final void doRun()
public final void stopWork()
WorkerThread
stopWork
in interface WorkerThread
public final void doTerminate()
WorkerThread
doTerminate
in interface WorkerThread
protected final void logMessage(String message)
message
- the message to logprotected abstract void doCleanUp()
protected abstract void doWork()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |