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 Multithreaded and SingleThreadModel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Multithreaded and SingleThreadModel" Watch "Multithreaded and SingleThreadModel" New topic

Multithreaded and SingleThreadModel

Jack Lau
Ranch Hand

Joined: Aug 30, 2002
Posts: 166
Hello All,

Since servlet by default is using multithread, multiple threads can access same servlet simutanously. Is there only one instance of each servlet (e.g. servletA) exists in the servlet container?

Also if implements SingleThreadModel, does it create more than one servlet (e.g. servletA) if there are more than 1 request?

Mikalai Zaikin
Ranch Hand

Joined: Jun 04, 2002
Posts: 3236
Hi Jack ,

Yes, by default only 1 instance of each Servlet exists in Servlet Container and serves multiple threads simultaneously.

If SingleThreadModel implemented, there are 2 options:
1) create pool of servlet instances and pass new request to new instance
2) serialize incoming request and put it in the queue to one servlet instance

1), or 2) - depends on servlet container implementation.


Free SCDJWS 5.0 Study Guide - SCDJWS 5.0 Quiz (How to get SCDJWS 5.0 Quiz)
Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam Study Guide and Quiz
Jack Lau
Ranch Hand

Joined: Aug 30, 2002
Posts: 166
Thank you!
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Multithreaded and SingleThreadModel