I am working on an enterprise application which is deployed to JBoss 4.2.3. It is using Servlet 2.5 specs.
The application has some JSPs which are using SingleThreadModel (STM) with this directive: <%@ page isThreadSafe="false" %>
I want to know how JBoss 4.2.3 implements SingleThreadModel (STM):
How can I find this information?
Thanks
As per JBOSS Documents, this can be done in both models:
The servlet container can make this guarantee by synchronizing access to a single instance of the servlet, or by maintaining a pool of servlet instances and dispatching each new request to a free servlet
And note that this is not completely thread safe:
Note that SingleThreadModel does not solve all thread safety issues
AND:
session attributes and static variables can still be accessed by multiple requests on multiple threads at the same time
So i think the answer is this directive (and also extending SingleThreadModel servlets) will prevent multiple threads to call service
method of a single instance of your servlet at the same time and will not prevent web server from serving simultaneous requests with multiple instances of the servlet.
In other words, One single instance will not serve requests in multiple threads at the same time, but web server can create multiple instances of the servlet and assign each request to one instance at the same time.
UPDATE
I found a constant of 20 maxInstances in catalina core that will instantiate up to 20 servlet instances to serve simultaneous requests received to a servlet, if there are no free instances,otherwise wait to have a free servlet instance.