Are there any examples online to see the synchronization done in servlet?

Singlethreadmodel will give take care of container which has servlet in it.
that means it will have only 1 thread activating the service() method? if so
how does the next incoming thread get the service() handle? Please let me
know exactly what happens with this model? is it internally implemented, or
we have to write it?

-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED] Behalf Of
Zoltan Szalay
Sent: Friday, July 25, 2003 8:48 AM
To: [EMAIL PROTECTED]
Subject: Re: multithreading


You must be right. What I wrote is only what SingleThreadModel is
designed for. The better choice is to do synchronization on your own.

On Fri, 2003-07-25 at 17:38, Milt Epstein wrote:
> 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
>

___________________________________________________________________________
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