Exactly. Remember, folks, SingleThreadModel is NOT the same as a Singleton,
in Design Patterns parlance.

Milt and/or Craig, you'll have to help me out on this, but I don't believe
the Servlet Spec even guarantees that servlets will reside in the same JVM,
correct? So the usual Singleton/Java-ism

public static MyServlet extends blah blah blah....
    implements blah blah blah...
{
    private static MySingleton singletonObject = new MySingleton();

    ...
}

cannot be guaranteed to only create one instance of the MySingleton type--it
will be one per JVM (per ClassLoader, if the servlet engine uses multiple
ClassLoaders, in fact).

Best to go another route if you're looking for Singletons in Servlets.

Ted Neward
CTO, WebRaiser ( http://www.webraiser.com )
Java Instructor, DevelopMentor ( http://www.develop.com )
Patterns/C++/Java/CORBA/EJB/COM-DCOM spoken here
http://www.javageeks.com/~tneward


-----Original Message-----
From: Milt Epstein <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Monday, November 08, 1999 9:15 AM
Subject: Re: Servlet Life Cycle - Single Thread Model


>On Mon, 8 Nov 1999, Siros Supavita wrote:
>
>> Hello all,
>>
>> >But, what is the meaning of "The servlet container can make this
>> >guarantee by synchronizing access to a single instance >of the
>> >servlet, or by maintaining a pool of servlet instances and
>> >dispatching each new request to a free servlet."?
>> >
>> >Does it mean multiple instances were created (Dynamically??) under
>> >server control? Any parameter to set, if any, this value, say in
>> >jserv with apache
>>
>> I'm not really sure what does this statement mean (I'm not familiar
>> with Jserv). But in servlet concept, it never creates duplicate
>> instant (to handle multiple request or whatever). This is advantage
>[ ... ]
>
>This is incorrect.  The servlet engine/container *can* create multiple
>instances of a servlet, and in fact this is what most do when a
>servlet implements SingleThreadModel (to help alleviate the
>performance penalties) -- that is what that statement means.  I
>believe most servlet engines/containers also allow control of the pool
>of servlet instances created (e.g. min and max).
>
>In fact, there was nothing stopping a servlet engine/container from
>creating multiple instances of a servlet even when it didn't implement
>SingleThreadModel, alhtough this has been clarified in the 2.2 spec.
>
>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

___________________________________________________________________________
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