|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.javagroups.util.ReusableThread
Reusable thread class. Instead of creating a new thread per task, this instance can be reused
to run different tasks in turn. This is done by looping and assigning the Runnable task objects
whose run
method is then called.
Tasks are Runnable objects and should be prepared to terminate when they receive an
InterruptedException. This is thrown by the stop() method.
The following situations have to be tested:
Constructor Summary | |
---|---|
ReusableThread()
|
|
ReusableThread(java.lang.String thread_name)
|
Method Summary | |
---|---|
boolean |
assignTask(java.lang.Runnable t)
Assigns a task to the thread. |
boolean |
available()
|
boolean |
done()
|
void |
resume()
Resumes the thread. |
void |
run()
Delicate piece of code (means very important :-)). |
void |
start()
|
void |
stop()
Stops the thread by setting thread=null and interrupting it. |
void |
suspend()
Suspends the thread. |
java.lang.String |
toString()
|
void |
waitUntilDone()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ReusableThread()
public ReusableThread(java.lang.String thread_name)
Method Detail |
public boolean done()
public boolean available()
public void start()
public void stop()
public void suspend()
public void resume()
public boolean assignTask(java.lang.Runnable t)
public void run()
run
in interface java.lang.Runnable
public void waitUntilDone()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |