You can also try using the TimerTask, as follows:

In the context.xml create a bean as follows:

<Resource name = "mytimerBean" auth="Container"
   type="org.silly.TimerBean"
   factory="org.apache.naming.factory.BeanFactory"
   param1="one thing"
   param2="two things" />


The TimerBean can be very simple. I typically have an init(), destroy(), and setters for the parameters (setParam1, setParam2). The Bean needs to create a Timer and can be used to invoke a TimerTask. All this is explained pretty thoroughly in the jdk 1.5.

To invoke the bean it can be done either through a servlet or a ServletListener. One of the nice things of doing it this way is that only one task will run at a time
 and it doesn't require much work to set up.

I'd be curious to see what people think of this idea, because even though it works well for me there might be a better way.

Richard Toren


Christopher K. St. John wrote:

On Sat, 18 Mar 2006 19:32:19 +0100
 "Clemens Eisserer" <[EMAIL PROTECTED]> wrote:


I've created a servlet wich creates some threads for doing background
stuff. ... now I subscribed to a servlet-hosting service which uses a
shared tomcat enviroment.
How does tomcat handle these threads?
Will they be destroyed by tomcat as soon as I click "stop" in Tomcat's
application manager or will I have to take care about them?


There's some good, in-depth discussion in the archives. It
needs some updating, but:
   http://www.distributopia.com/servlet_stuff/background_threads.html

is also reasonably informative.


-cks


--
Christopher St. John
http://artofsystems.blogspot.com
http://eventmirror.com


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

Reply via email to