aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Servlet Instance Pool - Java Servlet Specification V3.0 - 2.3.3.1 Multithreading Issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Servlet Instance Pool - Java Servlet Specification V3.0 - 2.3.3.1 Multithreading Issues" Watch "Servlet Instance Pool - Java Servlet Specification V3.0 - 2.3.3.1 Multithreading Issues" New topic
Author

Servlet Instance Pool - Java Servlet Specification V3.0 - 2.3.3.1 Multithreading Issues

Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

Hi All,

While reading through “2.3.3.1 Multithreading Issues” in “Java Servlet Specification V3.0” below statement is confusing me .
For servlets not implementing the SingleThreadModel interface, if the service method (or methods such as doGet or doPost which are dispatched to the service method of the HttpServlet abstract class) has been defined with the synchronized keyword, the servlet container cannot use the instance pool approach, but must serialize requests through it.

What does it mean by “Servlet Instance Pool”. As we know, there can be only one Servlet instance per declaration per JVM (in an non-distributed environment). Was “Thread Pool” misspelled as “Instance Pool” here? I believe Thread Pool also does not make any sense here. Tried search the web, but couldn’t get the relevant answers.

Thanks,
A.A.Anbarasu


A.A.Anbarasu
Tomasz Czerwinski
Greenhorn

Joined: Jun 04, 2012
Posts: 4
You are right, it`s pretty confusing.

The case is that (as you wrote), when Servlet doesn`t implement SingleThreadModel, only one instance of it will be created. And if you synchronize one of it`s methods (service(..), doPost(..), etc), container won`t be abe to use full potential of concurrent executions. Request to this servlets will be serialized, because each request-thread will block servlet for the time of it`s execution.
This situation is even worse than implementing SingleThreadModel. When your servlet implement it, you mark it for the container and the container can create many instances of the Servlet and pool them, so each thread will work on different servlet instance and it won`t be blocked (of course if there will be enough servlet instances).

So, by 'cannot use the instance pool approach', I would understand that:
-container won`t be able to gain benefits from concurrent threads working on one servlet instance.
 
 
subject: Servlet Instance Pool - Java Servlet Specification V3.0 - 2.3.3.1 Multithreading Issues
 
Similar Threads
when to use SingleThreadModle
Wonder about one of the SCWCD whizlabs question?
MultipleThreadModel disasters
about instance of servlet
Difference between "SingleThreadModel" and "synchronised"?