Why singlethreadmodel is deprecated in servlets




















The SingleThreadModel Interface is deprecated in this version of the specification. If a servlet implements SingleThreadModel interface, servlet container can create one or multiple instance of the servlet depend on the request load. Each instance will use only their service method. It solves thread safety issues but not all of them.

Such as static class variables, session attributes are still not thread safe. Instead of using this interface developer encouraged to use synchronizing the block of the code accessing those resources.

Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Ask Question. Asked 11 years, 7 months ago. Active 3 years, 3 months ago. Viewed 11k times. Improve this question. It is recommended that a developer take other means to resolve those issues instead of implementing this interface, such as avoiding the usage of an instance variable or synchronizing the block of the code accessing those resources.

This interface is deprecated in Servlet API version 2. Forum: Servlets. SingleThreadModel interface - deprecated. Vishwa Kumba. Operating System. Computer Network.

Compiler Design. Computer Organization. Discrete Mathematics. Ethical Hacking. Computer Graphics. Software Engineering. Web Technology. Cyber Security. C Programming. Control System. However, implementing the SingleThreadModel does not solve the synchronization problems that may occur if multiple servlet instances access the same shared resource outside the servlet class for example, a shared file, or database access.

Remember that several instances of the same servlet can exist if there are few servlets defined in the Web descriptor with the same classes.



0コメント

  • 1000 / 1000