| Author |
Question regarding SingleThreadModel
|
Gaurav Chhabras
Ranch Hand
Joined: Sep 21, 2005
Posts: 126
|
|
In one E - Book i have read that -: " Recall that multiple client requests to the same servlet result only in multiple threads calling the service method of a single servlet instance. They do not result in the creation of multiple servlet instances except possibly when the servlet implements SingleThreadModel." In above it is written that it will create multiple instance of Servlet if we implements SingleThreadmodel, but i think that only one instance of servlet is created , so how is it possible that many instance of one servlet will be created, it will nullify the usuage of servlet if it will create many instance of the same servlet. Thanks Regards Gaurav
|
 |
Mani Ram
Ranch Hand
Joined: Mar 11, 2002
Posts: 1140
|
|
From the Java API on SingleThreadModel As you can see, whether to create a single instance (and to provide a synchronized access) or to create multiple instances, depends on the implementation of the Servlet container. But if multiple instances are created, the containers generally pool them to improve the performance. [ November 23, 2005: Message edited by: Mani Ram ]
|
Mani
Quaerendo Invenietis
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Gaurav, This thread from last week might interest you. In it, singleThreadModel was discussed quite a bit. http://www.coderanch.com/t/361606/Servlets/java/Pooling-Servlet
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
 |
|
|
subject: Question regarding SingleThreadModel
|
|
|