Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question regarding SingleThreadModel

 
Gaurav Chhabras
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In one E - Book i have read that -:

" Recall that multiple client requests to the same servlet result only
in multiple threads calling the service method of a single servlet instance.
They do not result in the creation of multiple servlet instances except possibly when the servlet implements SingleThreadModel."

In above it is written that it will create multiple instance of Servlet if we implements SingleThreadmodel, but i think that only one instance of servlet is created , so how is it possible that many instance of one servlet will be created, it will nullify the usuage of servlet if it will create many instance of the same servlet.

Thanks
Regards
Gaurav
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the Java API on SingleThreadModel


As you can see, whether to create a single instance (and to provide a synchronized access) or to create multiple instances, depends on the implementation of the Servlet container.
But if multiple instances are created, the containers generally pool them to improve the performance.
[ November 23, 2005: Message edited by: Mani Ram ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gaurav,

This thread from last week might interest you.
In it, singleThreadModel was discussed quite a bit.

http://www.coderanch.com/t/361606/Servlets/java/Pooling-Servlet
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic