On Thu, 2 Nov 2000, Andras Balogh wrote:
> Hi,
>
> I would say DO NOT implement it. It will slow down your servlet
> very much. The only thing you have to do is be sure that your
> (multi threaded) servlet to be thread save. I can't understand 100%
> what means thread safe but you will have to take care about accesing
> global variables.
> If you acces (or modify) a global variable than you have to
> syncronize that block of code. Aslo you can syncronize a method.
> You can modify any object created in the service (doGet or doPost)
> because this will be thread safe.
> My advice is don't use STM and search the archives (i have seen
> on this list much better explanations about thread safe issues) or
> in books how to make your servlet thread safe.
I strongly concur, and many people on the list have also suggested
likewise when this has come up in the past.
SingleThreadModel is misleading in that it doesn't guarantee thread
safety in all situations, and there are some unintuitive consequences
to using it (e.g. the servlet container may create multiple instances
of the servlet, to help compensate for the performance penalty).
The best solution is to design your servlet so that it is thread safe,
and/or isolate the necessary synchronization to the smallest possible
code blocks.
> ----- Original Message -----
> From: "G S Sundar" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, November 02, 2000 7:52 AM
> Subject: Single Thread Model..
>
>
> > Hello All,
> > I would like to make my servlet application to be thread safe,
> > so, i'm trying to implement the SingleThreadMethod interface.
> > Can some one throw some light on it how to implement exactly
> > and sample code will be appriciated..
> >
> > SingleThreadModel:
> > As per the document, no two threads can call the service method at a time.
> > Or the servlet container maintain the pool of servlet instances(what is
> this
> > pool instances) and it will pass the request to the free instance..
> >
> > Thanx in advance
> >
> > Regards
> > G S Sundaram
> >
>
> ___________________________________________________________________________
> 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
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
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