Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

singlethreadmodel  RSS feed

 
sitaram irrinki
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose we r implementing a SingleThreadModel in our servlet, So Web Container will create more than 1 instances of our servlet..

But if large no of requests comes at a time to a web container & if there is no enough space on web container to create that many no of objects at a time.. then what will be the scenario
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could limit the number of HTTP connections to a number you can handle. Both Apache and Tomcat can do this, and I would assume all other web servers as well.
But maybe it might make sense to re-architect your servlet to either consume less resources or be multi-thread capable?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SingleThreadedModel is also deprecated so, unless you're already using it in an existing app, I wouldn't start writing servlets that implement it.
 
Ritesh Agrawal
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am not sure if one really needs to use SingleThreadModel now a days. I would rather use synchronized methods carefully if at all I have to than implementing a SingleThreadModel interface.
 
Avianu Sud
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In what situation would you want to run a SingleThread model for the servlet?
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In what situation would you want to run a SingleThread model for the servlet?

Never. The SingleThreadModel is no different than synchronizing your service method, which basically destroys your concurrency. It was depreciated because it does nothing but offer poor preformance.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It was actually deprecated because it was a little misleading.
The servlet itself is threadsafe but your not guaranteed thread safety when accessing session or context scoped objects.
They perform quite well in app servers that pool them (like Tomcat).

Nevertheless... They're depreprecated and that's reason enough not to start using them.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!