File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes SingleThreadModel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "SingleThreadModel" Watch "SingleThreadModel" New topic


Latha Kota
Ranch Hand

Joined: Mar 13, 2003
Posts: 35
I have come across this question in HFSJ mock exam. It says that this statement is true. Can anybody explain me why?

If the servlet does not implement SingleThreadModel, the container will create no more than one instance per JVM.

kapil munjal
Ranch Hand

Joined: May 11, 2004
Posts: 298
Yes, this statement is correct.

If we dont implement SingleThreadModel, then there will be only one instance of the servlet which will serve all the request.

If we implement SingleThreadModel, and we have to server 5 request simultaneously, only then we can do the configuration of creation of more than one instance of the servlet.

Kapil Munjal
SCJP 1.4, SCWCD 1.4
Mat Williams
Ranch Hand

Joined: Jul 20, 2005
Posts: 215

essentially if the Servlet does not implement SingleThreadModel then the server considers it to be thread safe, and thus all requests the go to the same instance of the servlet in different threads. This means, that at any one point in time, there may be more than one thread executing through the same servlet.


Latha Kota
Ranch Hand

Joined: Mar 13, 2003
Posts: 35
Thanks Kapil and Mat. I now understood it better.
SCJP 1.4
I agree. Here's the link:
subject: SingleThreadModel
It's not a secret anymore!