You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Kenneth H. Cox" <tc...@comcast.net> on 2004/03/01 18:55:00 UTC
Do servlet threads ever die?
Problem: I call native code (Tcl) from my servlet. Tcl's thread model
forces me to run Tcl only on the thread that created the Tcl interpreter.
So now how do I cleanup these interpreters? The cleanup code needs to be
run on the creating thread.
I am using Tomcat 5.
Do servlet threads ever die besides during shutdown? If not, I may have
no problem.
Can I register a listener to be invoked on the thread before it shuts
down? A Tomcat-specific answer is fine.
Suggestions very much appreciated.
Ken Cox
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Do servlet threads ever die?
Posted by Ronald Klop <ro...@base.nl>.
On Tue Mar 02 04:02:30 CET 2004 Christopher Schultz <ch...@comcast.net> wrote:
Ken,
>Problem: I call native code (Tcl) from my servlet. Tcl's thread model
>forces me to run Tcl only on the thread that created the Tcl
>interpreter. So now how do I cleanup these interpreters? The cleanup
>code needs to be run on the creating thread.
Guh. I highly recommend against running native code from an app server.
There are lots of reasons I could enumerate if you ask. Number one
reason: crashed native code = crashed server. :(
Is there a way you can call the Tcl code through a socket or by invoking
another process and communicating with it via stdin/stdout? (see
java.lang.Process)
>Do servlet threads ever die besides during shutdown? If not, I may have
>no problem.
AFAIK, Tomcat never retires threads unless something horrible happens
(or tomcat is shutting down).
>Can I register a listener to be invoked on the thread before it shuts
>down?
I don't think you can do this to a thread. You might be able to hack
Tomcat's thread pool so that you can cleanup after a thread if it's
going to be retired. I don't have any good ideas.
Sorry I couldn't help more.
-chris
Hello,
I use a webstart app with JINI for these things. Very easy. I can start a server on any host by webstart and it automaticly connects to the webserver by JINI.
You can also create a Thread of your own in the Tomcat server, which you control yourself, but indeed. If you native code crashes, your server crashes.
Ronald.
Re: Do servlet threads ever die?
Posted by Christopher Schultz <ch...@comcast.net>.
Ken,
> Problem: I call native code (Tcl) from my servlet. Tcl's thread model
> forces me to run Tcl only on the thread that created the Tcl
> interpreter. So now how do I cleanup these interpreters? The cleanup
> code needs to be run on the creating thread.
Guh. I highly recommend against running native code from an app server.
There are lots of reasons I could enumerate if you ask. Number one
reason: crashed native code = crashed server. :(
Is there a way you can call the Tcl code through a socket or by invoking
another process and communicating with it via stdin/stdout? (see
java.lang.Process)
> Do servlet threads ever die besides during shutdown? If not, I may have
> no problem.
AFAIK, Tomcat never retires threads unless something horrible happens
(or tomcat is shutting down).
> Can I register a listener to be invoked on the thread before it shuts
> down?
I don't think you can do this to a thread. You might be able to hack
Tomcat's thread pool so that you can cleanup after a thread if it's
going to be retired. I don't have any good ideas.
Sorry I couldn't help more.
-chris
Re: Do servlet threads ever die?
Posted by Antonio Fiol BonnĂn <fi...@terra.es>.
Hi,
Threads may die... depending on your config.
You can use the Servlet#destroy() method. (Not Tomcat-specific)
Yours,
Antonio Fiol
Kenneth H. Cox wrote:
> Problem: I call native code (Tcl) from my servlet. Tcl's thread model
> forces me to run Tcl only on the thread that created the Tcl
> interpreter. So now how do I cleanup these interpreters? The cleanup
> code needs to be run on the creating thread.
>
> I am using Tomcat 5.
>
> Do servlet threads ever die besides during shutdown? If not, I may
> have no problem.
>
> Can I register a listener to be invoked on the thread before it shuts
> down? A Tomcat-specific answer is fine.
>
> Suggestions very much appreciated.
>
> Ken Cox
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>