There's nothing more dangerous than a resourceful idiot. ---Dilbert
Rahul Mahindrakar
Ranch Hand
Joined: Jul 28, 2000
Posts: 1831
posted
0
Matt, Lets talk about dead threads Dead threads are threads that have completed their run() method. Now these threads cannot be started again as you know. Thus to "kill" the thread you will have to remove or make null any reference that exists to this thread object. The garbage collector will do it job of garbage collection. About Idle threads Idle thread are threads what do some work and wait for some event to continue working. To do this your program should contain the logic to exit the run method cleanly based on condition. It is not proper programming logic for you to "kill" a thread. The concept of "kill" of a thread has thus been "deprecated" if you check up the 1.2 api with the "deprecation" of the stop method and other methods. ------------------ Mahindrakar IBM Application Server Forum Moderator Consultant - Zensar Technologies. SCJP2, SCJD2 & SCJEA (Part I)
jeremy crosbie
Greenhorn
Joined: Jun 20, 2001
Posts: 23
posted
0
Originally posted by Matt Senecal: Any ideas?
Dead threads are, well, dead. They have been killed As far as idle threads the APIs for stopping threads have been deprecated. Reason being is that they were unsafe: if someone called Thread.stop() while the thread was performing work the state in which the thread terminates is unknown potentially causing bad results. What you can do is inside the class that implements Runnable or extends the Thread class is add a boolean flag. Normally that flag is set to false but when set to true the thread should be made to recognize it and stop gracefully. hope this helps.
Jeremy Crosbie<BR>Co-Author of <A HREF="http://www.amazon.com/exec/obidos/ASIN/186100401X/ref=ase_electricporkchop" TARGET=_blank rel="nofollow">Professional Java XML</A>
Matt Senecal
Ranch Hand
Joined: Dec 01, 2000
Posts: 255
posted
0
Thanks to the both of you!
Originally posted by jeremy crosbie: Dead threads are, well, dead. They have been killed As far as idle threads the APIs for stopping threads have been deprecated. Reason being is that they were unsafe: if someone called Thread.stop() while the thread was performing work the state in which the thread terminates is unknown potentially causing bad results. What you can do is inside the class that implements Runnable or extends the Thread class is add a boolean flag. Normally that flag is set to false but when set to true the thread should be made to recognize it and stop gracefully. hope this helps.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.