• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SingleThreadModel

 
Shirley Santiago
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The HFSJ says, if the servlet implements javax.servlet.SingleThreadModel, the container may create one instance for each request. Does it mean that it is possible to have multiple instances of servlet?

Then, the errata says that "If the servlet implements javax.servlet.SingleThreadModel, the container may use one instance for each simultaneous request."

Which one is true?

Thanks,
Shirley
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The SingleThreadModel ensured that one thread accessed an instance of the servlet. For performance gains some container pool instances so that more requests can be handled in parallel.
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there are many servlet instances and for each instance there is only one thread. So model is thread safe but it's deprecated due to poor performence.(HFSJ)
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there are many servlet instances and for each instance there is only one thread. So model is thread safe but it's deprecated due to poor performence.(HFSJ)
 
Shirley Santiago
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thank you for your replies.

I also saw this in the Servlet 2.4 Specs.

"For a servlet not hosted in a distributed environment (the default), the servlet container must use only one instance per servlet declaration. However, for a servlet implementing the SingleThreadModel interface, the servlet container may instantiate multiple instances to handle a heavy request load and serialize requests to a particular instance."

And yes, SingleThreadModel is deprecated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic