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 AServletCont

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'

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 mention

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 an

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

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 Interru

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 >> InterruptedE

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, b

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 ( InterruptedExc

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 h

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 Thre

Re: Terminating Timer Thread Gracefully

2011-07-13 Thread Pid
gt; 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:tere...@tmbsw.com] >>>> Subject: Terminating Timer Thread Gracefully

RE: Terminating Timer Thread Gracefully

2011-07-12 Thread Bill Miller
e to control Timer objects??) Bill -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 pr

Re: Terminating Timer Thread Gracefully

2011-07-12 Thread Terence M. Bandoian
, Jul 12, 2011 at 7:59 AM, Caldarale, Charles R 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 message disappeared. You should be able

Terminating Timer Thread Gracefully

2011-07-12 Thread Terence M. Bandoian
Thanks to all who replied. Functionally, the servlet context listener is implemented as follows: public class AServletContextListener implements ServletContextListener { private Timer timer; private ATimerTask timerTask; public AServletContextListener() { } public void

Re: Terminating Timer Thread Gracefully

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

Re: Terminating Timer Thread Gracefully

2011-07-12 Thread Kris Schneider
On Tue, Jul 12, 2011 at 10:03 AM, David kerber wrote: > On 7/12/2011 9:59 AM, Kris Schneider wrote: >> >> On Tue, Jul 12, 2011 at 7:59 AM, Caldarale, Charles R >>  wrote: >>>> >>>> From: Terence M. Bandoian [mailto:tere...@tmbsw.com] >

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 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

Re: Terminating Timer Thread Gracefully

2011-07-12 Thread Kris Schneider
On Tue, Jul 12, 2011 at 7:59 AM, Caldarale, Charles R 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 tim

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() us

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 cont

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 me

Terminating Timer Thread Gracefully

2011-07-11 Thread Terence M. Bandoian
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 perform periodic maintenance. To no avail, I spent quite