-----------------------------
Please read the FAQ!
<http://java.apache.org/faq/>
-----------------------------



Nimret Sandhu wrote:

> -----------------------------
> Please read the FAQ!
> <http://java.apache.org/faq/>
> -----------------------------
>
> hello all -
>
> this is more of a developer q. about servlet engine internals.
>
> i just noticed some 'interesting' behaviour using a tool that i have written
> for monitoring a running JVM. it seems that jserv creates a new thread to
> run a servlet in even when the servlet has already been loaded and kills it
> when the servlet is finished. is this 'correct' behaviour? arent servlets
> supposed to be loaded once and then 'cached' by the servlet engine? also, if
> i name the current thread in a servlet's service() method, it does not name
> the thread running that servlet. this would be consistent with the
> observation that jserv starts a new thread for a servlet and kills it when
> the servlet is finished with its service() method.
>

The servlet API says that a servlet *instance* has a lifecycle (call to init(),
potentially many calls to service(), and call to destro()).  It says absolutely
nothing about the creation or destruction of threads that call the methods of
that servlet object.  A servlet engine is free to choose whatever mechanism for
using threads it wants.

In particular, there is not a one-to-one correspondence between threads and
servlets.  For example, if there are several requests being processed by the
same servlet at the same time, they will all be active within the single
instance of the servlet object (unless your servlet implements the
"SingleThreadModel" interface).

Craig McClanahan




--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html/>
Problems?:           [EMAIL PROTECTED]

Reply via email to