A proper way to stop thread ?

2003-11-20 Thread Laurent Michenaud
Hi,
 
We are using Timer in our web application.
 
We are wondering how to stop the Timer when tomcat shutdown.
 
For the moment, we add Timer.cancel() in the destroy() of the servlet
that launches the Timer.
 
I don't know if it is good or not.
 
When is a servlet killed ? at tomcat shutdown or when it is not used
anymore ( GC ) ?


RE : A proper way to stop thread ?

2003-11-20 Thread eric perso
Put it on null ,not?

 -Original Message-
 From: Laurent Michenaud [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, November 20, 2003 5:26 PM
 To: [EMAIL PROTECTED]
 Subject: A proper way to stop thread ?
 
 
 Hi,
  
 We are using Timer in our web application.
  
 We are wondering how to stop the Timer when tomcat shutdown.
  
 For the moment, we add Timer.cancel() in the destroy() of the servlet
 that launches the Timer.
  
 I don't know if it is good or not.
  
 When is a servlet killed ? at tomcat shutdown or when it is not used
 anymore ( GC ) ?
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: A proper way to stop thread ?

2003-11-20 Thread Shapira, Yoav

Howdy,

We are using Timer in our web application.

We are wondering how to stop the Timer when tomcat shutdown.

For the moment, we add Timer.cancel() in the destroy() of the servlet
that launches the Timer.

I don't know if it is good or not.

When is a servlet killed ? at tomcat shutdown or when it is not used
anymore ( GC ) ?

A servlet is normally destroyed on server shutdown.  According to the
servlet specification, however, the container may destroy a servlet if
it needs to as long as it's not in use.

So you may wish to have the Timer shutdown elsewhere, such as in the
contextDestroyed method of a servlet listener.

Alternatively, you can run the Timer in a separate Thread as a daemon,
in which case the JVM will automatically shut it down when it shuts
down.  But you don't want to rely on this unless you have to.

Perhaps the better question is, why are you using such a long-lived
timer?

Yoav Shapira



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE : A proper way to stop thread ?

2003-11-20 Thread Laurent Michenaud
The goal of the timer is to update a cache.

Thanks for the idea of the context listener.

-Message d'origine-
De : Shapira, Yoav [mailto:[EMAIL PROTECTED] 
Envoyé : jeudi 20 novembre 2003 17:30
À : Tomcat Users List
Objet : RE: A proper way to stop thread ?


Howdy,

We are using Timer in our web application.

We are wondering how to stop the Timer when tomcat shutdown.

For the moment, we add Timer.cancel() in the destroy() of the servlet
that launches the Timer.

I don't know if it is good or not.

When is a servlet killed ? at tomcat shutdown or when it is not used
anymore ( GC ) ?

A servlet is normally destroyed on server shutdown.  According to the
servlet specification, however, the container may destroy a servlet if
it needs to as long as it's not in use.

So you may wish to have the Timer shutdown elsewhere, such as in the
contextDestroyed method of a servlet listener.

Alternatively, you can run the Timer in a separate Thread as a daemon,
in which case the JVM will automatically shut it down when it shuts
down.  But you don't want to rely on this unless you have to.

Perhaps the better question is, why are you using such a long-lived
timer?

Yoav Shapira



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]