This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Servlets and the fly likes Question regarding SingleThreadModel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Question regarding SingleThreadModel" Watch "Question regarding SingleThreadModel" New topic

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.

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 ]

Quaerendo Invenietis
Ben Souther

Joined: Dec 11, 2004
Posts: 13410


This thread from last week might interest you.
In it, singleThreadModel was discussed quite a bit.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: Question regarding SingleThreadModel
jQuery in Action, 3rd edition