This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

singlethread model

 
clyde melly
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if a servlet implements the singlethread model and suppose there are 10 requests,how many instances are created and how does the management for the request proceed.if the single thread model is not implemented then how many instances wud be created for the 10 requests as stated above.
 
unni krishna
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*** SingleThreadedModel is depricated. Now a days nobody uses it ****
If a servlet implements single threaded model, then one instance of that servlet can serve only one request at a time. The number of instances created can be specified by the user in web.xml.

If the servlet does not implement single threaded model, then with single instance, 10 requests can be served.
 
clyde melly
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so for 10 requests 10 instances ??? in which case implementing singlethreadedmodel?
 
unni krishna
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
friend, dont use singlethreaded model. if u implement single threaded model, then the number of requestes that can be served at a time is equal to the number of instances of the servlet that you create.
 
clyde melly
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i get it but just wanted to know how does the request management happen with both approach in details
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Funny how many of the same people who disparage SingleThreadModel are happy with EJBs Having said that, I would agree: don't use SingleThreadModel (or the JSP equivalent). Write threadsafe code. It's not that hard.

- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic