Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFJS question 13 page 214

 
Jeff MacDonald
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For me, there is no correct answer. Is there only one instace of a servlet with different thread for each request? no matter whether the servlet is SingleThreadModel or not.

Can anyone tell me why A and D are correct please?

Any help is very appreciated!!
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For each incoming request container creates a seperate thread to handle the request. For example 10 users access the same servlet resource then 10 threads will be created by the container but there will be only one instance of that servlet.

Whereas when your servlet implements SingleThreadModel no more than one thread can access your servlet. It's just lik synchronizing your service method. So the container creates sepeate instance for every incoming request. with SingleThreadModel concurrency(multiple threads accessing the same resource) is severely affected. So it is appreciable NOT to use SingleThreadModel. Thats the reason why they had deprecated it from servlet spec 2.4
 
Jeff MacDonald
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Vishnu. Now I get it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic