tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Terence M. Bandoian" <tere...@tmbsw.com>
Subject RE: Terminating Timer Thread Gracefully
Date Thu, 14 Jul 2011 06:00:22 GMT
  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, but as you mentioned
before you
> don't have access to the true thread instance in this case.

That's how it looks to me.  Time and possibly a context switch.

> I'd say that the Thread.sleep() is doing the same as a Thread.join() would in this case,
the only
> problem I see is that if your application is intended to run on different hardware the
hardcoded
> 1000ms delay may not be long enough in some situations. :(

Right.

> Have you checked to see if there are any methods available to indicate if the timer has
completed
> its shutdown? (My memory is unclear about this and the JavaDoc isn't handy either...
maybe there's
> another object you need to instantiate to control Timer objects??)

Nothing in Timer.  Seems like I could potentially create a Thread and 
roll my own timing mechanism and then interrupt and join the Thread in 
contextDestroyed but that may be more complexity than is warranted.  
Might be fun though.

> Bill

Thanks.

-Terence


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


Mime
View raw message