tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: Own Threads within TC ?
Date Fri, 01 Mar 2002 16:42:06 GMT


On Fri, 1 Mar 2002, Lauer, Oliver wrote:

> Date: Fri, 1 Mar 2002 16:41:17 +0100
> From: "Lauer, Oliver" <Oliver.Lauer@AXA.de>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: "Tomcat Users List (E-Mail)" <tomcat-user@jakarta.apache.org>
> Subject: Own Threads within TC ?
>
> Hi,
>
> I know within an EJB container you mustn't use threads although in some you
> can either. How is that topic related to TC.
> I know I can use threads within TC but what does the spec. says about
> threads ? I want to start some within a servlet's init() and stop those
> using the destroy() method.
>
> Is that ok and allowed as well ?
>

Tomcat itself doesn't stop you from doing this (unless you run under a
security manager with a policy that prohibits thread creation).  A couple
of things to keep in mind:

* Threads should normally be created as daemon threads
  (thread.setDaemon(true) after creation).  Otherwise,
  Tomcat will hang forever at shutdown time unless your
  code correctly cleans up the threads it created.

* It is not valid to keep a reference to objects provided
  by the container (HttpServletRequest, HttpServletResponse)
  beyond the scope of a particular call to the service()
  method of your servlet.  You'll need to copy everything
  you need out of these objects before the servlet call
  finishes.

> Thanks
> Oliver
>

Craig


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message