How we can makes a servlet thread safe?

Questions by ranjansukrit

Showing Answers 1 - 3 of 3 Answers

delindia fathima

  • Dec 8th, 2006
 

We can make our servlets thread safe by surrounding the block of code with the synchronized blocks.While a particular synchronized block is executing,no other section of code that are synchronized to the same block can execute.

But a more complex servlet need to synchronize its entire method,limiting the servlet to one request at a time.This can be done by implementing SingleThreadModel interface. It has no methods.It tells the server to create a pool of instance, instead of single instance of the servlet.

Delindia fathima

  Was this answer useful?  Yes

ambar

  • Dec 28th, 2006
 

by using syn

  Was this answer useful?  Yes

srikiran_bab@yahoo.com

  • Jan 4th, 2007
 

By implementing SingleThreadModel interface in javax.servlet. package to your servlet you can make the servlet single threaded and another thing is it does'nt contains any methods the web server will takes care about your servlet

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions