How would you declare a SingleThreaded servlet

Showing Answers 1 - 12 of 12 Answers

Yogesh

  • Jun 1st, 2005
 

class serverlet_name extends HttpServlet implements SingleThreadModel { 
......... 
......... 
......... 
}

krishna

  • Jul 7th, 2005
 

threads

  Was this answer useful?  Yes

srinivasa Reddy

  • Aug 4th, 2005
 

The other method is put the Syncronized keyword prior to servlice method defination. 
ex: syncronized public void service(HttpServletRequest rq,HttpServletResponse rs){ 
}

  Was this answer useful?  Yes

Pavan

  • Sep 1st, 2005
 

By implementing SingleThreadModel we can do. If we do like that then for each request one servlet instance will be created. Normally only one servlet instance will be there for any number of requests. Number of threads will be created corresponding to the requests. Implementing the SingleThreadModel will create additional burden on the container. So use it carefully when required.

deepak

  • Sep 28th, 2005
 

single thread servlet can be created by implementing SingleThreadModel interface.it does not require any special method to mmplement,just your class need to implement that interface and than only one object of that servlet will be created

seshu

  • Oct 14th, 2005
 

One can also use synchronized classes to  ensure only one instance of class is running.

  Was this answer useful?  Yes

mayur

  • Aug 15th, 2007
 

We can put the code in the servlet in a synchronized block with a static member as a monitor.

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