The original 'doc' came from 'Symantec'; below I am including the doc from
'Sun'.

The last sentence of the 'Sun' doc does point out the exceptions under which
a servlet will not be Thread Safe using 'SingleThreadModel'.

So, rather than just cover the most trivial of cases I'm inclined to say
that the 'SingleThreadModel' provides integrity in a great many cases.  If
you need to utililze 'static class variables or classes outside the scope of
the servlet' then you should provide your own synchronization for those
objects.  All I've got to say.

>From Sun:

"
public abstract interface SingleThreadModel
Ensures that servlets handle only one request at a time. This interface has
no methods.

If a servlet implements this interface, you are guaranteed that no two
threads will execute concurrently in the servlet's service method. The
servlet engine can make this guarantee by synchronizing access to a single
instance of the servlet, or by maintaining a pool of servlet instances and
dispatching each new request to a free servlet.

If a servlet implements this interface, the servlet will be thread safe.
However, this interface does not prevent synchronization problems that
result from servlets accessing shared resources such as static class
variables or classes outside the scope of the servlet.
"

Sigler

-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Craig
R. McClanahan
Sent: Friday, February 11, 2000 12:49 AM
To: [EMAIL PROTECTED]
Subject: Re: AW: Servlet Life Cycle


Ron Sigler wrote:

> >From the doc --
>
> "
> public abstract interface SingleThreadModel
>
> Defines a "single" thread model for servlet execution. This empty
interface allows servlet implementers to specify how the system should
handle concurrent calls to the same servlet.
> If the target servlet is flagged with this interface, the servlet
programmer is guaranteed that no two threads will execute concurrently the
service method of that servlet. This guarantee is ensured by maintaining a
pool of servlet instances for each such servlet, and dispatching each
service call to a free servlet.
>
> In essence, if the servlet implements this interface, the servlet will be
thread safe.
>

Only in the most trivially simple cases is this statement correct.  You
still need to be very aware that you are operating in a multi-threaded
servlet environment.  This is one of the biggest gripes I have about the
very existence of the "SingleThreadModel" interface -- it misleads people
into a false sense of security
that they don't have to worry about multithreading.

Craig McClanahan

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to