Killing JAVA threads in background

Hi All,

We have hosted a website in a particular Linux web server. Whenever the tomcat restarts, my JAVA program (WTLogFilePhantom) will start a new Thread, but those threads are not stopped yet (forget to invoke the stop method).

Now the problem is, there are many thread processes which are running in the server. I want to kill those processes from background. How can I identify those processes.

Please advice,

Thanks

Malai

[464 byte] By [malaiselvana] at [2007-11-27 2:09:53]
# 1
Whenever u closed ur connection just call the current Thread to exit... then the thread goes to dead state.. This can be achieved by using Thread.currentThread().interrupt().stop and suspend are also used..
83Krisha at 2007-7-12 2:00:56 > top of Java-index,Java Essentials,Java Programming...
# 2
No, Thread.stop() and Thread.suspend() are not used, they are heavily deprecated.
ejpa at 2007-7-12 2:00:57 > top of Java-index,Java Essentials,Java Programming...
# 3

First off, these days we don't stop threads - we ask them politely to terminate. These background threads typically loop, with a wait or sleep in the loop. You set a flag to break the loop and call interrupt to kick the thread out of wait or sleep.

What exactly do you mean by "kill those processes from background." if you mean you want them to close with the server, use a ContextListener.

If you want to stop them from outside of the server then the best way is probably to have a special web transaction which triggers a servlet to do the shut down.

malcolmmca at 2007-7-12 2:00:57 > top of Java-index,Java Essentials,Java Programming...
# 4
You can get current thread by calling method Thread.currentThread().After getting that thread call Thread.stop().Message was edited by: abhijitva
abhijitvaa at 2007-7-12 2:00:57 > top of Java-index,Java Essentials,Java Programming...
# 5
> After getting that thread call Thread.stop().No, no, no, no, no. That method has been deprecated for about eleven years. It is unsafe. Do not use it. Do not recommend it to other people. Do read the Javadoc before you make recommendations about things you haven't used
ejpa at 2007-7-12 2:00:57 > top of Java-index,Java Essentials,Java Programming...
# 6
> you haven't used yourselfI suppose he uses it in large enterprise applications as a commonplace practice. -_-;Stop blind outsourcing.
hiwaa at 2007-7-12 2:00:57 > top of Java-index,Java Essentials,Java Programming...
# 7

Stop exporting jobs overseas, and importing questions about how to do them back to these forums, and exporting the answers which are generally either misunderstood or ignored or both, and also stop importing the poorly written rubbish that results, and is obviously being written out there, judging by the quality of the questions that get asked. Just imagine the ones that don't get asked ...

ejpa at 2007-7-12 2:00:57 > top of Java-index,Java Essentials,Java Programming...