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


Please Help Members By Posting Answers For Below Questions

What are the uses of servlets?

619


What is setattribute in servlet?

552


What is the element?

585


What is java servlet?

606


How can you create a session in servlet?

591






What is cgi and what are its drawbacks?

549


How native code can be used in a servlet?

3518


When should you prefer to use doget() over dopost()?

661


What is MIME Type?

661


What is the difference between Servlet Request and Servlet Context when calling a Request Dispatcher?

598


What are the different methods involved in the process of session management in servlets?

661


How can we refresh automatically when new data is entered into the database?

595


Can we refresh servlet in client and server side automatically?

591


What is the workflow of a servlet?

719


What is called Session Tracking?

596