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 the use of servlet wrapper classes?
Which application server is best for java?
What is the difference between the http servlet and generic servlet?
Why HttpServlet class is declared abstract?
What is the difference between using getSession(true) and getSession(false) methods?
How to handle exceptions thrown by application with another servlet?
Differentiate between the web server and application server?
Tell us something about servletconfig interface.
How do you run a servlet?
How can a servlet be used to generate plain text instead of html?
How do I use cookies to store session state on the client?
What are the different methods of session management in servlets?
what do you understand by url rewriting?
What are its drawbacks of cgi?
Explain the lifecycle of a servlet?