>clean up stopped or interrupted threads. JProfiler tells me that more
>an

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
First of, thanks for your reply Roedy!
I do actually interrupt the threads! I should just let the threads "run
out" of their run methods? Should this really solve the problem? It
would be great! Is it better to let some sort of ThreadPool manage the
lifetime of the threads? I am really uncomfortable producing so many
threads and fire and forgetting them but this was the easiest and
fastest way to implement this application.
Roedy Green - 13 Nov 2005 17:07 GMT
>I do actually interrupt the threads! I should just let the threads "run
>out" of their run methods? Should this really solve the problem? It
>would be great! Is it better to let some sort of ThreadPool manage the
>lifetime of the threads? I am really uncomfortable producing so many
>threads and fire and forgetting them but this was the easiest and
>fastest way to implement this application.
Have a look at http://mindprod.com/jgloss/queue.html
and follow the links in into the Sun documentation on the new
concurrent classes. They give you all sorts of ways of managing thread
pools.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Steve Horsley - 13 Nov 2005 17:49 GMT
> First of, thanks for your reply Roedy!
>
[quoted text clipped - 4 lines]
> threads and fire and forgetting them but this was the easiest and
> fastest way to implement this application.
I strongly suspect that Threads don't become eligible for GC
until after they return from run(). I presume that stopping the
thread prevents it from ever retuning.
I don't see what interrupting it has to do with this though. You
may change its course, wake it from some blocking state, but
until it returns from run() it is alive and cannot be GCd
whatever it is doing.
The normal way to kill threads is to tell them you wish them to
quit - set a flag they look at from time to time (interrupting
sets a flag they can check with isInterrupted IIRC). When they
see they are no longer wanted, then they can clean up, releasing
any locks or other resources they hold and return (run out from
run) in their own time. They don't have to explicitly de-allocate
Objects that they hold, because the GC will clean those up.
Steve
DrChaos - 17 Nov 2005 17:19 GMT
I would agree that this is the best code safe way to deal with live
threads. Manageable and predictable. From a thread manager, track who
is alive if they where asked to quit and when they have actually
returned/quit.
-DrChaos
>> First of, thanks for your reply Roedy!
>>
[quoted text clipped - 22 lines]
>
> Steve
Thomas G. Marshall - 14 Nov 2005 18:40 GMT
WonderboyFromMars@googlemail.com coughed up:
> First of, thanks for your reply Roedy!
>
[quoted text clipped - 4 lines]
> threads and fire and forgetting them but this was the easiest and
> fastest way to implement this application.
Could you elaborate a little on why you think you need a great number of
threads?
Most of the times I've seen this, the designer was very much mistaken.

Signature
"So I just, uh... I just cut them up like regular chickens?"
"Sure, just cut them up like regular chickens."