Meaningless Drivel is fun!
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
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: 3281
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.


Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam Study Guide and Quiz
Exam 1Z0-810: Upgrade to Java SE 8 Programmer Study Guide and Quiz
Jack Lau
Ranch Hand

Joined: Aug 30, 2002
Posts: 166
Thank you!
Consider Paul's rocket mass heater.
subject: Multithreaded and SingleThreadModel