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 are Servlets?
What is the major difference between context parameter and context attribute?
Explain the jar and war files in servlet?
Difference between httpservlet and generic servlets?
How do you design microservices?
Write the code to get the server information in servlet.
Which http method is said to be non-idempotent and idempotent?
What is java servlet?
Explain how to improve Servlet Performance?
Write a simple servlet program to print the contents of html.
Whether we can get deadlock situation in servlets?
How do I support both get and post from the same servlet?
How can you create a session in servlet?
Why are http servlets used in programming?
What exception should be thrown when servlet is not properly initialized?