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 do you mean by interservlet communication?
What is servlet initializer?
What do you mean by web applications?
Is it good idea to create servlet constructor?
Is servlet synchronized?
What are different ways for servlet authentication?
What do you mean by cgi?
Can you refresh servlet in client and server-side automatically?
When servlet object is created?
What is the use of attribute in servlets?
What is the difference between forward () and sendredirect () functions in servlet? Explain
Differentiate between get and post?
Explain their methods? Tell me their parameter names also have you used threads in servlet?
What is a servlet context object?
What is the use of servlet wrapper classes?