|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jgroups.util.ReusableThread
public class 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.
Field Summary | |
---|---|
protected static org.apache.commons.logging.Log |
log
|
Constructor Summary | |
---|---|
ReusableThread()
|
|
ReusableThread(java.lang.String thread_name)
|
Method Summary | |
---|---|
boolean |
assignTask(java.lang.Runnable t)
Assigns a task to the thread. |
void |
assignThreadLocalListener(ThreadLocalListener tl_listener)
Assigns a ThreadLocalListener to the current ReusableThread. |
boolean |
available()
|
boolean |
done()
|
boolean |
isAlive()
|
void |
resume()
Resumes the thread. |
void |
run()
Delicate piece of code (means very important :-)). |
void |
start()
Will always be called from synchronized method, no need to do our own synchronization |
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 |
Field Detail |
---|
protected static final org.apache.commons.logging.Log log
Constructor Detail |
---|
public ReusableThread()
public ReusableThread(java.lang.String thread_name)
Method Detail |
---|
public boolean done()
public boolean available()
public boolean isAlive()
public void start()
public void stop()
public void suspend()
public void resume()
public boolean assignTask(java.lang.Runnable t)
public void assignThreadLocalListener(ThreadLocalListener tl_listener)
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 |