reuse a thread which is no longer "alive"

S

sayoyo

Hi,

Is there some way that we can reuse a thread by replacing the runnable
object of the thread? like a thread is not "alive" anymore, then we remove
the runnable object(is it possible????) and then run it again.

Thanks you very much

Sayoyo
 
M

Michael Borgwardt

sayoyo said:
Is there some way that we can reuse a thread by replacing the runnable
object of the thread? like a thread is not "alive" anymore, then we remove
the runnable object(is it possible????) and then run it again.

Not on that level, no.

But it's not all that difficult to write a class that takes a Runnable,
executes its run() method and then waits to recieve a new Runnable instead
of finishing its own run() method. This is known as a thread pool:
http://www-106.ibm.com/developerworks/java/library/j-jtp0730.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top