Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 85805 invoked from network); 13 Sep 2008 06:34:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Sep 2008 06:34:45 -0000 Received: (qmail 45183 invoked by uid 500); 13 Sep 2008 06:34:28 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 45157 invoked by uid 500); 13 Sep 2008 06:34:28 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 45146 invoked by uid 99); 13 Sep 2008 06:34:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Sep 2008 23:34:28 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [196.25.240.79] (HELO ctb-mesg-1-1.saix.net) (196.25.240.79) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 13 Sep 2008 06:33:28 +0000 Received: from animal (dsl-243-106-51.telkomadsl.co.za [41.243.106.51]) by ctb-mesg-1-1.saix.net (Postfix) with SMTP id 0813F357B for ; Sat, 13 Sep 2008 08:33:14 +0200 (SAST) Message-ID: <002501c9156a$bd602040$0300000a@animal> From: "Johnny Kewl" To: "Tomcat Users List" References: <7947dd030809121613r5ed139c9gc0f6fb90bb326f90@mail.gmail.com> Subject: Re: Tomcat shutdown event Date: Sat, 13 Sep 2008 08:34:03 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Antivirus: avast! (VPS 080805-0, 2008/08/05), Outbound message X-Antivirus-Status: Clean X-Virus-Checked: Checked by ClamAV on apache.org ----- Original Message ----- From: "Tom Cat" To: "Tomcat Users List" 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