Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When to use SingleThreadModel?

 
Dez Max
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,
I've a doubt in using SingleThreadModel interface. I understand that it ensures no two thread can access the service method of the servlet that implements this interface at any given point in time. But practically when should we be using it. You guys have any idea. If so, a practical scenario would be appreciated.
regs
Fred
 
Leena Diwan
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I too am waiting for this answer. A business requirement which forces us to go for a SingleThreadModel !

Thanks and Regards,
Leena
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would only use SingleThreadModel if it is impossible for some reason to write your servlet class without using instance variables to hold data related to the request.
I have never seen an example in real life code.
I would love to hear a description of business requirements that forced you to use SingleThreadModel.
Note that it simply ensures at each servlet instance only handles one request at a time. The servlet engine may create multiple instances.
Bill
[ December 13, 2002: Message edited by: William Brogden ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Fred",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp.
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please edit your profile and select a new name which meets the requirements.
Thanks.
Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic