hi friends, it seems confusing that there's a servlet pool in the single-thread model. if we implement a servlet SingleThreadModel, no two threads will execute concurrently in the servlet's service method. in this situation, what's the use of a pool of servlet instances? i think one instance is okay, right? tony
Hi Tony, SingleThreadModel results in ThreadSave member variables of the servlet. If u have > 1 servlets (servlet-pool) the member variables per instance are still thread-safe. A Servlet pool leads to faster response time. That makes sense to me, because SingleThreadModel slows down the response time.
hi axel, do you know what's a servlet pool? it's a number of servlet objects (instances) associated with the same servlet name. each of the instances is ready (initialized) to be dispatched to a request thread by the container. i'm not sure the defination i gave is right any ideas on it, friends? tony
3.2 Number of Instances By default, there must be only one instance of a servlet class per servlet definition in a container. In the case of a servlet that implements the SingleThreadModel interface, the servlet container may instantiate multiple instances of that servlet so that it can handle a heavy request load while still serializing requests to a single instance. In the case where a servlet was deployed as part of an application that is marked in the deployment descriptor as distributable, there is one instance of a servlet class per servlet definition per VM in a container. If the servlet implements the SingleThreadModel interface as well as is part of a distributable web application, the container may instantiate multiple instances of that servlet in each VM of the container. 3.2.1 Note about SingleThreadModel The use of the SingleThreadModel interface guarantees that one thread at a time will execute through a given servlet instance’s service method. It is important to note that this guarantee only applies to servlet instance. Objects that can be accessible to more than one servlet instance at a time, such as instances of HttpSession, may be available to multiple servlets, including those that implement SingleThreadModel, at any particular time.
(Servlet 2.2 specs on servlet instances) -anthony
See ya later boys, I think I'm in love. Oh wait, she's just a tiny ad:
a bit of art, as a gift, that will fit in a stocking