You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Clemens Eisserer <li...@gmail.com> on 2006/03/18 19:32:19 UTC

Tomcat and Threads

Hello,

I've created a servlet wich creates some threads for doing background
stuff. Till now I never worried about these thread since I was
runnning this servlet only on my own servers.

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

Thank you in advance, lg Clemens

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


Re: Tomcat and Threads

Posted by Richard Toren <ri...@supportx.com>.
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" <li...@gmail.com> 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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


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


Re: Tomcat and Threads

Posted by Clemens Eisserer <li...@gmail.com>.
Hi again,

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

Thanks a lot for mentioning this article - wow i think i could have
caused troubles on my hoster's server ;)

Since I need to deploy to many different servlet-containers (some of
them are seriously broken) I chose the do-it-yourself way.
SingleTon-designed Thread-Manager which stops all threads in destroy.

Thanks for the tip, lg Clemens

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


Re: Tomcat and Threads

Posted by "Christopher K. St. John" <ck...@distributopia.com>.
On Sat, 18 Mar 2006 19:32:19 +0100
  "Clemens Eisserer" <li...@gmail.com> 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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org