On Fri, 1 Mar 2002, Lauer, Oliver wrote:
> Date: Fri, 1 Mar 2002 16:41:17 +0100
> From: "Lauer, Oliver" <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: "Tomcat Users List (E-Mail)" <[EMAIL PROTECTED]>
> 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:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>