Re: Stop thread when undeploying

Niall Gallagher <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
>I have a web application, and a servlet creates a thread.
>
>I want to destroy the thread while undeploying or when the servlet receive
>an specific option.
>
>I tried to interrupt the thread but it doesn't works. It throws an
>interruption exception. Sleep interrupted and the thread runs forever even
>though the application is undeployed.
>
>How can I stop the thread ??
>
>I'm using jboss-3.0.0_tomcat-4.0.3.


Hi,

Iin regards to your question of how to stop a thread, typically what is needed is for a signal of some sort to be sent to the thread. It is considered "sloppy" to use the depreciated Thread.stop method, however it is an option. What you will need is to ensure that the Runnable extends some interface that can accept a signal like:

public interface Signalable {

   public static final int KILL = 0;

   public static final int ?? = ?


   public void send(int signal);

   // or perhaps

   public void kill();

}

I hope I have understood your question correctly.

Niall.

___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.