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...@attbi.com> on 2003/05/28 23:11:15 UTC

How do I listen for threads starting and stopping?

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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


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

Posted by "Kenneth H. Cox" <tc...@attbi.com>.
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 <wb...@wilshire.com> 
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" <tc...@attbi.com> wrote in message
> news:oprpwig1cl3ocmvz@mail.attbi.com...
>> 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: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>



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

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


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

Posted by Bill Barker <wb...@wilshire.com>.
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" <tc...@attbi.com> wrote in message
news:oprpwig1cl3ocmvz@mail.attbi.com...
> 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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org