|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
nl.knowledgeplaza.util.thread.WorkerThread
public class WorkerThread
This is a basic worker thread. New runnables can be added to it and they will be executed in sequence. An exeception in a runnable will not cause the work to abort. Use the ThreadUtils' setStopFlag to stop the worker thread. By setting the override property, new runnables are not just added at the end of the queue, but the queue is emptied before. This ensures that at maximum one runnable is executing, and one is queued, because already running runnables are allowed to finish normally. This is useful for situation where screen contents is refreshing using this class, but a new refresh is needed before the 1st completes (so the 2nd will be queued), and a 3rd refresh is needed. The 1st and 2nd refresh actually are useless, since they will be overriden with the 3rd. The 1st is already executing, so not much can be done there, but when replace is true, the 2nd will be removed from the queue and the 3rd inserted.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
static java.lang.String |
SOURCECODE_VERSION
Standard variable for determining version of a class file. |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
WorkerThread()
|
|
WorkerThread(java.lang.String name)
|
|
| Method Summary | |
|---|---|
void |
add(java.lang.Runnable r)
Add a new runnable to the worker thread |
void |
add(java.lang.String name,
java.lang.Runnable r)
Description for a task |
static WorkerThread |
createAndStart()
|
static WorkerThread |
createAndStart(boolean override)
|
static WorkerThread |
createAndStart(java.lang.String name,
boolean override)
|
java.lang.String |
getActivityDescription()
|
java.lang.String |
getActivityDescription(java.lang.String prefix)
|
boolean |
getOverride()
|
boolean |
isBusy()
true if this thread still has work to do |
static void |
main(java.lang.String[] args)
|
void |
run()
|
void |
setOverride(boolean override)
override will make sure only one runnable is queued at any time |
| 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, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String SOURCECODE_VERSION
| Constructor Detail |
|---|
public WorkerThread()
public WorkerThread(java.lang.String name)
| Method Detail |
|---|
public static WorkerThread createAndStart()
public static WorkerThread createAndStart(boolean override)
override -
public static WorkerThread createAndStart(java.lang.String name,
boolean override)
name - override - public void setOverride(boolean override)
public boolean getOverride()
public void add(java.lang.Runnable r)
public void add(java.lang.String name,
java.lang.Runnable r)
name - r - public java.lang.String getActivityDescription(java.lang.String prefix)
public java.lang.String getActivityDescription()
public void run()
run in interface java.lang.Runnablerun in class java.lang.Threadpublic boolean isBusy()
public static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||