SingleThreadModel(STM)
Understanding this interface is crucial in understanding how a wrapper loads a servlet.
According to the Servlet specification, the purpose of implementing this interface is to gurantee that the servlet handles only one request at a time.
//不能防止由于共享资源引起的同步问题
The interface does not prevent synchronization problems that result from servlets accessing shared resources such as static class variables or classes outside the scope of the servlet.
Deprecated in Servlet 2.4 due to it gives servlet programmers false sense of muti-thread safety.
If the StandardWrapper were to maintain a single instance of the STM servlet, here is how it would invoke the STM servlet’s service method:
Servlet instance = <get an instance of the servleet>;
if(servlet implementing SingleThreadModel){
synchronized(instance){
instance.service(request,response);
}
}else{
instance.service(request,response);
}
For the sake of performance, StandardWrapper maintains a pool of STM servlet instances.
* A wrapper is also responsible for preparing a javax.servlet.ServletConfig instance that can be obtained from inside the servlet.*