Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 45467688F for ; Tue, 12 Jul 2011 19:45:52 +0000 (UTC) Received: (qmail 83366 invoked by uid 500); 12 Jul 2011 19:45:44 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 82679 invoked by uid 500); 12 Jul 2011 19:45:44 -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 82669 invoked by uid 99); 12 Jul 2011 19:45:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jul 2011 19:45:43 +0000 X-ASF-Spam-Status: No, hits=1.0 required=5.0 tests=SPF_SOFTFAIL X-Spam-Check-By: apache.org Received-SPF: softfail (athena.apache.org: transitioning domain of terence@tmbsw.com does not designate 207.44.152.30 as permitted sender) Received: from [207.44.152.30] (HELO secure.savvysites.net) (207.44.152.30) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jul 2011 19:45:37 +0000 Received: from [192.168.1.3] (adsl-208-191-156-72.dsl.hstntx.swbell.net [208.191.156.72]) (authenticated bits=0) by secure.savvysites.net (8.12.10/8.12.10) with ESMTP id p6CJirOj026983 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 12 Jul 2011 14:44:54 -0500 Message-ID: <4E1CA4C1.8030609@tmbsw.com> Date: Tue, 12 Jul 2011 14:47:13 -0500 From: "Terence M. Bandoian" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.4) Gecko/20100608 Lightning/1.0b2 Thunderbird/3.1 MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Terminating Timer Thread Gracefully References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, Kris- I tried using ScheduledExecutorService but ran into the same problem. After awaiting termination: executorService.shutdown(); try { while ( !executorService.awaitTermination( 1, TimeUnit.SECONDS ) ); Thread.sleep( 1000 ); } catch ( InterruptedException ie ) { } I still had to insert a call to Thread.sleep to prevent the error message from being written to the logs. Thanks. -Terence Bandoian On 1:59 PM, Kris Schneider wrote: > On Tue, Jul 12, 2011 at 7:59 AM, Caldarale, Charles R > wrote: >>> From: Terence M. Bandoian [mailto:terence@tmbsw.com] >>> Subject: Terminating Timer Thread Gracefully >>> Finally, in contextDestroyed, I inserted a call to >>> Thread.sleep after canceling the timer and the error >>> message disappeared. >> You should be able to do a Thread.join() using the timer's Thread object rather than sleeping. > But Timer doesn't expose its thread. An alternative would be use > something like Executors.newSingleThreadScheduledExecutor() to get a > ScheduledExecutorService. The executor can be used to schedule a > Runnable with a fixed rate or delay. When the context is destroyed, > shutdown the executor and await its termination. > >> - Chuck --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org