On Fri, 25 Jul 2003, Zoltan Szalay wrote:

> If your servlet implements SingleThreadModel the container will take the
> responsibility to do synchronization. So you can be sure only one thread
> will execute e.g. the service() method at a time.
> Otherwise when you access or mutate the servlet instance/static fields
> from inside the service() method, you must protect your fields from
> concurrent access with synchronized blocks.

This isn't quite right.  SingleThreadModel really only gives you a
false sense of avoiding synchronization issues (there's lots of
discussion of this in the list archives, and probably elsewhere, like
in newsgroups and on the web).  Consensus opinion is not to use it.
In fact, it's been deprecated in the latest servlet spec.  The real
solution is to analyze your code for synchronization issues, and
eliminate/isolate them as much as possible, and then use synchronized
blocks and/or methods.


> On Fri, 2003-07-25 at 16:54, Shivanjali Bhutkar wrote:
> > I would like to know about multithreading in servlets.
> > Is the SingleThreadModel used when mutlithreading or not? If no then what's
> > the purpose of it and what is generally done when servlet is used by many
> > concurrent users at same time.
> > thanks
> >
> > ___________________________________________________________________________
> > 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
>

Milt Epstein
Research Programmer
Integration and Software Engineering (ISE)
Campus Information Technologies and Educational Services (CITES)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]

___________________________________________________________________________
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