Have you considered using Quartz to run recurring jobs? 

It comes with a Servlet that can be used to initialize your jobs when Tomcat 
starts up :)

-----Original Message-----
From: Asensio, Rodrigo [mailto:[EMAIL PROTECTED]
Sent: Monday, April 03, 2006 12:51 PM
To: Tomcat Users List
Subject: RE: How to run a thread on app startup


I didn't use ServletContextlistener beause my inner classes don't know
anything about a servlet or http (MVC) and the core is used across
services, swing and swt applications, etc.

-----Original Message-----
From: Bruce McGuire [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 03, 2006 3:46 PM
To: Tomcat Users List
Subject: Re: How to run a thread on app startup

Hello  Rodrigo.

Thanks very much for the information.

Bruce.

Asensio, Rodrigo wrote:

>I figured out that the best way to do that is with a variable of type 
>InheritableThreadLocal that keeps a copy per thread.
>
>We have 4 webapps over the same framework and all works in the same
way.
>The servlet creates a new instance of MyApplication and sets this 
>"singleton by thread" in the MyApplication class
>Application.set(myApplication)
>After that, all threads created based in the servlet thread will have 
>the same copy of your App.
>
>Regards
>
>-----------------------------------------------------------------------
>-
>------------
>Rodrigo Asensio
>Fuel Management Services
>Gilbarco Veeder Root
>phone: +1 336 547 5023
>
>
>-----Original Message-----
>From: Bruce McGuire [mailto:[EMAIL PROTECTED]
>Sent: Monday, April 03, 2006 3:31 PM
>To: users@tomcat.apache.org
>Subject: How to run a thread on app startup
>
>  
>
>>Hello.
>>
>>I need to have an application that has a seperate thread that loads 
>>when tomcat loads. It scans my db every once in a while, to find out 
>>if any new info has to be processed.
>>
>>I have tried to find out from the docs how to do this, but I can't 
>>find it.
>>
>>Thanks for your help,
>>
>>Bruce.
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>This message (including any attachments) contains confidential and/or 
>proprietary information intended only for the addressee.
>Any unauthorized disclosure, copying, distribution or reliance on the 
>contents of this information is strictly prohibited and may constitute 
>a violation of law.  If you are not the intended recipient, please 
>notify the sender immediately by responding to this e-mail, and delete 
>the message from your system.  If you have any questions about this 
>e-mail please notify the sender immediately.
> 
>Ce message (ainsi que les eventuelles pieces jointes) est exclusivement

>adresse au destinataire et contient des informations confidentielles. 
>La copie, la communication ou la distribution du contenu de ce message 
>sans l'accord prealable de l'expediteur sont strictement interdits et 
>peuvent constituer un delit. Si vous n'etes pas destinataire de ce 
>message, merci de le detruire et d'avertir l'expediteur. Si vous avez 
>des questions se rapportant a ce courrier electronique, merci de bien 
>vouloir notifier l'expediteur immediatement.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>  
>


This message (including any attachments) contains confidential 
and/or proprietary information intended only for the addressee.  
Any unauthorized disclosure, copying, distribution or reliance on 
the contents of this information is strictly prohibited and may 
constitute a violation of law.  If you are not the intended 
recipient, please notify the sender immediately by responding to 
this e-mail, and delete the message from your system.  If you 
have any questions about this e-mail please notify the sender 
immediately.  
 
Ce message (ainsi que les eventuelles pieces jointes) est 
exclusivement adresse au destinataire et contient des 
informations confidentielles. La copie, la communication ou la 
distribution du contenu de ce message sans l'accord prealable de 
l'expediteur sont strictement interdits et peuvent constituer un 
delit. Si vous n'etes pas destinataire de ce message, merci de le 
detruire et d'avertir l'expediteur. Si vous avez des questions se 
rapportant a ce courrier electronique, merci de bien vouloir 
notifier 
l'expediteur immediatement.

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


!DSPAM:44317d0f80311804284693!


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

Reply via email to