I have confusion regarding Single Thread Model and Multithread Model. What type of model SpringMVC works on?
Thank you
If you mean "does Spring MVC implement the javax.servlet.SingleThreadModel interface?" then it does not.
SingleThreadModel guarantees that "servlets handle only one request at a time." ( from the API docs ). This is generally managed by the servlet container which will maintain a pool of Servlet instances and allocate one to each incoming request. This is a rarely used model of execution, and the interface itself has been deprecated as of Java Servlet API 2.4, with no direct replacement.
With Spring MVC you should assume that your controller will be handling more than one request at a time, which makes it your responsibility to ensure that your processing is thread-safe.
SpringMVC controllers are singletons, and serve concurrent requests. They are used in a multithreaded fashion, and so must be written to be threadsafe (no shared state between executions).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With