If you're running on a J2EE app server, or a servlet container
configured with appropriate security policies, you won't be allowed to
start a new thread.

As to why it might be a bad idea, servlet containers make the
assumption that the request and response objects they hand to your
servlet will only be accessed on a single thread, because the servlet
spec includes that requirements.  Way too many developers who are
novices at threads try things like accessing the request object from
both the "real" thread provided by the container, and from a second
thread that they have started separately.  Or, they expect that they
can save a reference to a particular request beyond the lifetime of
the current request, not aware that the container might be recycling
those objects for some future request.  Doing this sort of thing leads
to undefined and inconsistent behavior that is extremely difficult to
debug.

Finally, way too many developers forget that a thread started by an
application is only known to that application (not to the container)
so it is your responsibiity to shut it down when the app is
undeployed, or when the server is shut down.

Craig


On Mon, 6 Dec 2004 11:48:15 -0700, Jim Barrows <[EMAIL PROTECTED]> wrote:
> Okay... I know I've read this somewhere, but can't remember.
> Why is it recommended you NOT start a thread inside a servlet, which would 
> translate to "Why is it a bad idea to start a thread inside an action?".
> And, can you point me at some documentation?
> 
> ---------------------------------------------------------------------
> 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