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
Explain their methods? Tell me their parameter names also have you used threads in servlet?
Explain the steps involved in placing a servlet within a package?
Define context initialization parameters.
Elucidate servlet attributes and its scope?
What is servlet and its advantages?
What are the steps that are required to handle the multi-threading?
Write a program to show the functionality of doget and dopost method?
What are the drawbacks of cgi?
How the servlet is loaded?
Explain the difference between servlet and cgi?
Why the concept of single thread model interface is used?
When is the servlet instance created in the life cycle of servlet? What is the importance of configuring a servlet?
What are the different methods of session management in servlets?
What are important features of Servlet 3?
How can we refresh automatically when new data has entered the database?