tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johnny Kewl" <j...@kewlstuff.co.za>
Subject Re: Tomcat shutdown event
Date Sat, 13 Sep 2008 06:34:03 GMT

----- Original Message ----- 
From: "Tom Cat" <tom.cat2170@gmail.com>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Saturday, September 13, 2008 1:13 AM
Subject: Tomcat shutdown event


> Hello,
>
> I have a servelet spawn a thread that should run until tomcat is
> shutdown. The problem is, when Tomcat is shut down, the thread keeps
> running.
>
> Does Tomcat have a shutdown event that I could use to trigger the
> thread destruction? If not, is there any graceful way of handling
> this?
>
> Thanks

A servlet has two overrides that you may find useful...

init
destroy

One is called at the very beginning of life and one at the end...

If the thread is active, one could poll a
mustIContinue flag... and if Destroy set that false the thread falls thru. 
after cleaning up...
Killing threads is not a thing to do ever... idea should be for the 
"service" to clean up and end itself.

If its a waiting thread... then you also have to wake it up so it can get 
out...

Alot to do with design...

On some systems...a third party engine, like an indexer can take a long time 
to finish and dont expose any controls, like interrupt me now.... engines 
like that are a problem....

I havent experienced any problems with letting a service thread run "after 
tomcat", in my case it is indexing engines that may run for 2 or 3 mins 
after tc has said goodbye... thats ok... but it depends on what you 
doing....

If your "service" should be ending... its a batch... and the batch is 
actually completing... but TC is cleaning up nicely... thats a bug, refs 
holding somewhere... you got to find em ;)

Anyway dont bang it closed...
---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message