On Fri, 3 Nov 2000, Nic Ferrier wrote:
> >>> Bo Xu <[EMAIL PROTECTED]> 03-Nov-00 10:08:37 PM >>>
>
> >because now *counter* and *lock* are instance field, so if there
> >are a instance pool which includes several instances of the class
> >Counter, now diferrent thread will be made by diferrent instance,
> >and so they will use diferrent *lock* to lock the code, and so now
> >perhaps there are more than one threads will run the same code
> >co-currently. and now I guess the sum of all counter is the
> >accessing time we want to get.
>
> i) as Craig explained, instance pools are ONLY used when you have a
> servlet which implements SingleThreadModel. The reason for that is
> to try and increase throughput to such Servlets.
[ ... ]
(I'm sure Nic knows this, but to clarify :-):
I think technically this is only guaranteed for servlet containers
that implement the latest (i.e. 2.2) servlet spec. That's because
it's the first revision of the spec to cover this behavior
specifically; previously it was not mentioned, and hence was
implementation dependent. However, many, if not most, if not all,
servlet engines/containers behaved this way even before it was
mandated by the spec.
My point is that if you're using a pre-2.2 servlet engine/container,
this behavior is *likely* the case, but not *guaranteed* (and if you
are using a 2.2 servlet container, it is guaranteed).
> The spec is explicit about having ONLY ONE instance of a servlet for
> each:
>
> <servlet>...</servlet>
>
> decleration in the web.xml.
>
> ii) if there IS more than one instance then you're right that there
> will be different locks... BUT there will also be different counter
> variables (duh! /8-)
[ ... ]
Again, to add a bit of clarification/elaboration, this means that
there will be one servlet instance for each "named" servlet (I'm not
sure if that's the official term, but I'm talking about each
<servlet>...</servlet> tag, as Nic mentioned). So there could be more
than one instance of the servlet, and more than one set of the
instance variables. But, as Nic suggests, if it was set up this way,
it is probably because the instances are logically distinct, and hence
having multiple sets of instance variables is probably the desired
behavior.
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