Gokul Singh wrote:

> ----- Original Message -----
> From: "Bo Xu" <[EMAIL PROTECTED]>
>
> >   *  SingleThreadModel is non_multi-thread: so it is thread-safty but it
> is not
> >        multi-thread-safty.  But we also can think it is the safest way of
> >       multi-thread-safty :-)
>
> Single thread model is thread safe for the member variables of a class, but
> as the container *may* instantiate more than one instance, it is not thread
> safe for static variables, if any. Another fallback of this is if you are
> using a non static member variable, each instance will have it's own copy
> which may cause some problems e.g. if you used it to keep count of the
> number of hits.
>
>  >    *  I guess if we use SingleThreadModel, the Servlet container
>  >        will have to work *harder*, and the efficacy is lower(because
>  >        now for a Servelt class which implements SingleThreadModel,
>  >        at any time, only zero/one client can access it ). and from
> several
>  >        emails, it is not good to use SingleThreadModel in a *real
>  >        system*-> it is for testing(?) or other purpose.
>
> In a real environment, there can be N number of requests being processed
> simultaneously by a servlet (each being a seperate thread). But if you use
> SingleThreadModel, you limit the number of simultaneous request being
> processed to the number of instances created by the container, which can
> even be 1 !.
>
> > Bo
>
> Regds,
> Gokul
> [...]

Hi Gokul,  thanks for your email! :-)    the following is my new understanding
of SingleThreadModel  after I read your email:

# if my Servlet class implements SingleThreadModel, then for every Servlet
definition,
   Servlet container will make a instance pool(which includes n instances) from
my
   Servlet class.

#  so now:
        * Servlet container will use one instance in this pool to make a thread
for
           a new client accessing
        * and in any time( define by Newton, not by Einstein:-) ),  we can not
find
           two threads which are from the same instance.
        * we will not have n+1 threads in any time.

#  so in fact SingleThreadModel is still similar with multi-thread, but is a
*limited*
    multi-thread-> every thread must from different instance in that pool.


Is the above right? please give me some directions!


Thanks in advance!


Bo
Dec.08, 2000

___________________________________________________________________________
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