Re: Terminating Timer Thread Gracefully

2011-07-24 Thread Terence M. Bandoian
For anyone who might be interested, this is what I ended up with for a scheduler: public class AServletContextListener implements ServletContextListener { private ScheduledExecutorService executor; /** * Constructs AServletContextListener object. */ public

Re: Terminating Timer Thread Gracefully

2011-07-15 Thread Mark Thomas
On 14/07/2011 23:59, Terence M. Bandoian wrote: On 1:59 PM, Mark Thomas wrote: On 14/07/2011 06:11, Terence M. Bandoian wrote: I can live with this. It's just one of those it would be nice not to have to explain things and if Thread.sleep does the trick, I'm happy. As I mentioned in my

Re: Terminating Timer Thread Gracefully

2011-07-15 Thread Terence M. Bandoian
On 1:59 PM, Mark Thomas wrote: On 14/07/2011 23:59, Terence M. Bandoian wrote: On 1:59 PM, Mark Thomas wrote: On 14/07/2011 06:11, Terence M. Bandoian wrote: I can live with this. It's just one of those it would be nice not to have to explain things and if Thread.sleep does the trick, I'm

Re: Terminating Timer Thread Gracefully

2011-07-14 Thread Pid
On 14/07/2011 06:05, Terence M. Bandoian wrote: On 1:59 PM, Pid wrote: ATimerTask is a private instance in AServletContextListener, is this necessary and if so, why? What logic is contained in ATimerTask? Are you overriding TimerTask.cancel() and do you catch InterruptedException? p

Re: Terminating Timer Thread Gracefully

2011-07-14 Thread Terence M. Bandoian
On 1:59 PM, Pid wrote: On 14/07/2011 06:05, Terence M. Bandoian wrote: On 1:59 PM, Pid wrote: ATimerTask is a private instance in AServletContextListener, is this necessary and if so, why? What logic is contained in ATimerTask? Are you overriding TimerTask.cancel() and do you catch

Re: Terminating Timer Thread Gracefully

2011-07-14 Thread Mark Thomas
On 14/07/2011 06:11, Terence M. Bandoian wrote: I can live with this. It's just one of those it would be nice not to have to explain things and if Thread.sleep does the trick, I'm happy. As I mentioned in my original post, I wanted to find out if there was a another way to accomplish the same

Re: Terminating Timer Thread Gracefully

2011-07-14 Thread Terence M. Bandoian
On 1:59 PM, Mark Thomas wrote: On 14/07/2011 06:11, Terence M. Bandoian wrote: I can live with this. It's just one of those it would be nice not to have to explain things and if Thread.sleep does the trick, I'm happy. As I mentioned in my original post, I wanted to find out if there was a

Re: Terminating Timer Thread Gracefully

2011-07-13 Thread Pid
On 12/07/2011 20:47, Terence M. Bandoian wrote: Hi, Kris- I tried using ScheduledExecutorService but ran into the same problem. After awaiting termination: executorService.shutdown(); try { while (

Re: Terminating Timer Thread Gracefully

2011-07-13 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Terence, On 7/12/2011 3:47 PM, Terence M. Bandoian wrote: executorService.shutdown(); try { while ( !executorService.awaitTermination( 1, TimeUnit.SECONDS ) ); Thread.sleep( 1000 ); } catch ( InterruptedException ie ) { } We use a

Re: Terminating Timer Thread Gracefully

2011-07-13 Thread Terence M. Bandoian
On 1:59 PM, Pid wrote: ATimerTask is a private instance in AServletContextListener, is this necessary and if so, why? What logic is contained in ATimerTask? Are you overriding TimerTask.cancel() and do you catch InterruptedException? p Hi, Pid- For the sake of clarity, I'll repeat this

Re: Terminating Timer Thread Gracefully

2011-07-13 Thread Terence M. Bandoian
On 1:59 PM, Christopher Schultz wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Terence, On 7/12/2011 3:47 PM, Terence M. Bandoian wrote: executorService.shutdown(); try { while ( !executorService.awaitTermination( 1, TimeUnit.SECONDS ) ); Thread.sleep( 1000 ); } catch (

RE: Terminating Timer Thread Gracefully

2011-07-13 Thread Terence M. Bandoian
On 1:59 PM, Bill Miller wrote: The problem is obviously that the thread within the Timer needs time to properly shutdown, the non-obvious part is how long does it need, and how do you detect it's done?. Normally you would do a Thread.join() to ensure a thread has stopped before continuing,

Re: Terminating Timer Thread Gracefully

2011-07-12 Thread Pid
On 12/07/2011 02:06, Terence M. Bandoian wrote: Hi- I've been testing a web application on: Tomcat 6.0.32 (32-bit) Sun/Oracle JRE 1.6.0_25 (32-bit) Windows Server 2008 R2 The web application includes a ServletContextListener which creates a Timer in the contextInitialized method to

Re: Terminating Timer Thread Gracefully

2011-07-12 Thread David kerber
On 7/12/2011 4:11 AM, Pid wrote: On 12/07/2011 02:06, Terence M. Bandoian wrote: Hi- I've been testing a web application on: Tomcat 6.0.32 (32-bit) Sun/Oracle JRE 1.6.0_25 (32-bit) Windows Server 2008 R2 The web application includes a ServletContextListener which creates a Timer in the

RE: Terminating Timer Thread Gracefully

2011-07-12 Thread Caldarale, Charles R
From: Terence M. Bandoian [mailto:tere...@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

Re: Terminating Timer Thread Gracefully

2011-07-12 Thread Kris Schneider
On Tue, Jul 12, 2011 at 7:59 AM, Caldarale, Charles R chuck.caldar...@unisys.com wrote: From: Terence M. Bandoian [mailto:tere...@tmbsw.com] Subject: Terminating Timer Thread Gracefully Finally, in contextDestroyed, I inserted a call to Thread.sleep after canceling the timer and the error

Re: Terminating Timer Thread Gracefully

2011-07-12 Thread David kerber
On 7/12/2011 9:59 AM, Kris Schneider wrote: On Tue, Jul 12, 2011 at 7:59 AM, Caldarale, Charles R chuck.caldar...@unisys.com wrote: From: Terence M. Bandoian [mailto:tere...@tmbsw.com] Subject: Terminating Timer Thread Gracefully Finally, in contextDestroyed, I inserted a call to

Re: Terminating Timer Thread Gracefully

2011-07-12 Thread Kris Schneider
On Tue, Jul 12, 2011 at 10:03 AM, David kerber dcker...@verizon.net wrote: On 7/12/2011 9:59 AM, Kris Schneider wrote: On Tue, Jul 12, 2011 at 7:59 AM, Caldarale, Charles R chuck.caldar...@unisys.com  wrote: From: Terence M. Bandoian [mailto:tere...@tmbsw.com] Subject: Terminating Timer

Re: Terminating Timer Thread Gracefully

2011-07-12 Thread Len Popp
On Tue, Jul 12, 2011 at 10:03, David kerber dcker...@verizon.net wrote: On 7/12/2011 9:59 AM, Kris Schneider wrote: On Tue, Jul 12, 2011 at 7:59 AM, Caldarale, Charles R chuck.caldar...@unisys.com wrote: From: Terence M. Bandoian [mailto:tere...@tmbsw.com] Subject: Terminating Timer

Re: Terminating Timer Thread Gracefully

2011-07-12 Thread Terence M. Bandoian
Hi, Kris- I tried using ScheduledExecutorService but ran into the same problem. After awaiting termination: executorService.shutdown(); try { while ( !executorService.awaitTermination( 1, TimeUnit.SECONDS ) );

RE: Terminating Timer Thread Gracefully

2011-07-12 Thread Bill Miller
-Original Message- From: Terence M. Bandoian [mailto:tere...@tmbsw.com] Sent: July 12, 2011 3:47 PM To: Tomcat Users List Subject: Re: Terminating Timer Thread Gracefully Hi, Kris- I tried using ScheduledExecutorService but ran into the same problem. After awaiting termination