Do servlet threads ever die?

2004-03-01 Thread Kenneth H. Cox
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: How do I listen for threads starting and stopping?

2003-05-31 Thread Kenneth H. Cox
Sorry; I was unclear.  I'm planning to use TclBlend to start one
Tcl interpreter per thread (a Tcl interp cannot jump threads and
so cannot be pooled).  Starting and initializing these interps is
somewhat heavyweight, so my plan was to keep them around until
Tomcat discards the thread or the thread dies of natural causes,
at which point I would like to be notified, so I can free my interp
(and the memory allocated by its native code).
Unless (duh?) a ThreadLocal variable will do this for me.  Yes,
it seems that it will.  Thanks for kicking my brain back into gear.
p.s. Any other Tomcat / TclBlend users out there?  I'm hunting
for a combination of JDK/TclBlend/Tcl/Thread that play together.
Ken

On Wed, 28 May 2003 22:00:56 -0700, Bill Barker [EMAIL PROTECTED] 
wrote:

The simplest (portable) way to do this is to pretend that Threads are the
same as Requests, and use request.setAttribute(foo,bar).  These will
automatically be discarded (i.e. eligible for GC) at the end of the 
Request.
If you need to do explicit cleanup, then you have to wait for TC 5.x, 
which
has RequestListeners to tell you when the Request starts and ends.

Kenneth H. Cox [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
I have some per-thread data that I need to dispose of
when Tomcat connector thread goes away.  I'm using the
Coyote Connector.  Is there a way to do it?  A Tomcat-specific
mechanism is just fine for now, thank you.
I found HttpConnector.addLifecycleListener(), but all the
methods are marked deprecated and I'm not sure how to get at the
HttpConnector in the first place.
Any pointers in the right direction would be greatly appreciated.

Regards,
kenstir
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


How do I listen for threads starting and stopping?

2003-05-29 Thread Kenneth H. Cox
I have some per-thread data that I need to dispose of
when Tomcat connector thread goes away.  I'm using the
Coyote Connector.  Is there a way to do it?  A Tomcat-specific
mechanism is just fine for now, thank you.
I found HttpConnector.addLifecycleListener(), but all the
methods are marked deprecated and I'm not sure how to get at the 
HttpConnector in the first place.

Any pointers in the right direction would be greatly appreciated.

Regards,
kenstir
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]