|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread tyrex.util.BackgroundThread
This thread allows a runnable to run continously until the runnable is garbage collected.
The thread waits for n number of milliseconds before running the runnable. The wait-run execution occurs in an infinite loop. If the runnable is garbage collected then the thread exits its loop and stops running.
For best results the runnable should not have an embedded loop. Obviously if the runnable has an infinite loop then this thread never ends by itself.
Field Summary |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
BackgroundThread(java.lang.Runnable runnable,
long wait)
Create the BackgroundThread. |
|
BackgroundThread(java.lang.Runnable runnable,
long wait,
java.lang.String name)
Create the BackgroundThread. |
|
BackgroundThread(java.lang.Runnable runnable,
long wait,
java.lang.ThreadGroup threadGroup)
Create the BackgroundThread. |
|
BackgroundThread(java.lang.Runnable runnable,
long wait,
java.lang.ThreadGroup threadGroup,
java.lang.String name)
Create the BackgroundThread. |
Method Summary | |
boolean |
getExitOnInterrupt()
Return true if the background thread exits when it is interrupted. |
long |
getWait()
Return the time in milliseconds to wait before the runnable is run. |
void |
run()
Run the runnable. |
void |
setExitOnInterrupt(boolean exitOnInterrupt)
Tell the background thread to exit or not, when it is interrupted. |
void |
setWait(long wait)
Set the time in milliseconds to wait before the the runnable is run. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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 |
Constructor Detail |
public BackgroundThread(java.lang.Runnable runnable, long wait)
runnable
- the runnable to runwait
- the time to wait before the runnable
is run.public BackgroundThread(java.lang.Runnable runnable, long wait, java.lang.String name)
runnable
- the runnable to runwait
- the time to wait before the runnable
is run.name
- the name of the Thread. Cannot be null.public BackgroundThread(java.lang.Runnable runnable, long wait, java.lang.ThreadGroup threadGroup)
runnable
- the runnable to runwait
- the time to wait before the runnable
is run.threadGroup
- the thread group of the new thread. Can br null.public BackgroundThread(java.lang.Runnable runnable, long wait, java.lang.ThreadGroup threadGroup, java.lang.String name)
runnable
- the runnable to runwait
- the time to wait before the runnable
is run.threadGroup
- the thread group of the new thread. Can br null.name
- the name of the Thread. Cannot be null.Method Detail |
public boolean getExitOnInterrupt()
public void setExitOnInterrupt(boolean exitOnInterrupt)
exitOnInterrupt
- True if the background thread
exits when it is interruptedpublic long getWait()
public void setWait(long wait)
wait
- the wait time in milliseconds.
Must be greater than 0.public void run()
If the runnable has been garbage collected the thread ends.
The thread sleeps the prescribed number of seconds before running the runnable. The wait-run execution occurs in an infinite loop
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |