You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by TK Banks <sp...@yahoo.com> on 2004/11/09 23:40:30 UTC

Killing threads during context restart

I have a background thread object in my tomcat
application that performs some garbage-collection like
functions (i.e., wakes up periodically and does some
application specific cleanup).  I have tomcat
configured to "restart the context" when I drop new
class files in the WEB-INF/classes directory. 
Recently I have discovered multiple copies of my these
background threads running simultaneously.  Further
investigation has shown that I get an additional copy
with each context restart.

I guess I don't even know what a context is, but I
assumed that a context restart would kill off all
application threads.  How am I supposed to get all my
application threads to die when the context restarts? 
Checking instance variables don't work since the data
from the old context and the new does not appear to be
shared.

Thanks much,
Matt


		
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 


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


Re: Killing threads during context restart

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "TK Banks" <sp...@yahoo.com>
> I guess I don't even know what a context is, but I
> assumed that a context restart would kill off all
> application threads.  How am I supposed to get all my
> application threads to die when the context restarts?

What about creating a ServletContextListener?  With that you will be
notified when the context is initialized and destroyed, and you have the
opportunity to start and stop your background process.

I think, though, that you're officially discouraged from starting additional
threads... at least that's the impression I've always gotten.  I looked in
the specification, and found that containers are allowed to restrict you
from creating Thread objects, (Servlet 2.3, SRV.1.2) though I don't think
Tomcat does.

-- 
Wendy  Smoak



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


Re: Killing threads during context restart

Posted by TK Banks <sp...@yahoo.com>.
Thanks all.  I have the threads dying cleanly now.

--- Filip Hanik - Dev <de...@hanik.com> wrote:

> you can setup context listeners, and when the
> context is stopped you will receive an event and can
> stop your bg thread
> 
> Filip
> ----- Original Message ----- 
> From: "TK Banks" <sp...@yahoo.com>
> To: <to...@jakarta.apache.org>
> Sent: Tuesday, November 09, 2004 4:40 PM
> Subject: Killing threads during context restart
> 
> 
> I have a background thread object in my tomcat
> application that performs some garbage-collection
> like
> functions (i.e., wakes up periodically and does some
> application specific cleanup).  I have tomcat
> configured to "restart the context" when I drop new
> class files in the WEB-INF/classes directory. 
> Recently I have discovered multiple copies of my
> these
> background threads running simultaneously.  Further
> investigation has shown that I get an additional
> copy
> with each context restart.
> 
> I guess I don't even know what a context is, but I
> assumed that a context restart would kill off all
> application threads.  How am I supposed to get all
> my
> application threads to die when the context
> restarts? 
> Checking instance variables don't work since the
> data
> from the old context and the new does not appear to
> be
> shared.
> 
> Thanks much,
> Matt
> 
> 
> 
> __________________________________ 
> Do you Yahoo!? 
> Check out the new Yahoo! Front Page. 
> www.yahoo.com 
>  
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tomcat-user-help@jakarta.apache.org
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tomcat-user-help@jakarta.apache.org
> 
> 



		
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 


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


Re: Killing threads during context restart

Posted by Filip Hanik - Dev <de...@hanik.com>.
you can setup context listeners, and when the context is stopped you will receive an event and can stop your bg thread

Filip
----- Original Message ----- 
From: "TK Banks" <sp...@yahoo.com>
To: <to...@jakarta.apache.org>
Sent: Tuesday, November 09, 2004 4:40 PM
Subject: Killing threads during context restart


I have a background thread object in my tomcat
application that performs some garbage-collection like
functions (i.e., wakes up periodically and does some
application specific cleanup).  I have tomcat
configured to "restart the context" when I drop new
class files in the WEB-INF/classes directory. 
Recently I have discovered multiple copies of my these
background threads running simultaneously.  Further
investigation has shown that I get an additional copy
with each context restart.

I guess I don't even know what a context is, but I
assumed that a context restart would kill off all
application threads.  How am I supposed to get all my
application threads to die when the context restarts? 
Checking instance variables don't work since the data
from the old context and the new does not appear to be
shared.

Thanks much,
Matt



__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 


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

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