How to make servlet thread safe?
Answer Posted / bhaskar padala
The servlet programmer should implement SingleThreadModel interface to ensure that servlet can handle only one request at a time. It is a marker interface, means have no methods.
This interface is currently deprecated since Servlet API 2.4 because it doesn't solves all the thread-safety issues such as static variable and session attributes can be accessed by multiple threads at the same time even if we have implemented the SingleThreadModel interface. So it is recommended to use other means to resolve these thread safety issues such as synchronized block etc.
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
What is a cookie What is the difference between session and cookie
Why the container loads server at the application startup and how?
What is servlet and list its types?
Explain the jar and war files in servlet?
What is the procedure of invoking different servlet in a different application?
How the servlet is loaded?
What is the use of java servlet api?
What is called servlet mapping?
How to get ip address in jsp login page and how to validate like 127.1.0.1 all should not be greater than 255
Define the lifecycle for executing a jsp page.
What is http servlet?
Describe in brief RequestDespatcher?
How the typical servlet code look like ?
How can the session in servlet can be destroyed?
What are the steps that are involved in using the httpservlet class?