• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SingleThread Model

 
rex tony
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is SingleThread Model?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is a deprecated API.

In a nut shell, if a servlet implements Single Thread Model, the container will provide a new copy of it for each request. It was deprecated because its name gave the false impression that implementing it guaranteed thread safety.
 
sudhir nim
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a servlet is implementing SingleThreadModel thn container will synchronize access to service(). threre can not be more thn one thread running through service method.

Yes, it is deprecated
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sudhir nim:
If a servlet is implementing SingleThreadModel thn container will synchronize access to service()


No, this is one way in which it can be implemented.

From the API:
The servlet container can make this guarantee by synchronizing access to a single instance of the servlet, or by maintaining a pool of servlet instances and dispatching each new request to a free servlet.
 
sudhir nim
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya thats true.
Whatever the case, container guarantees that only one thread is accessing service() method at a time.

It is irrelevant, I think programmer doesnt need to know weather container is
synchronizing the access or maintaining the pool.
[ November 05, 2007: Message edited by: sudhir nim ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not irrelevant, it's the API.
 
sudhir nim
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its transparent to developer.
Developer doesnt need to know it.
What one could achieve if he know that container has pooled the servlet instances and not synchronized the service method()?

You may correct me if I am wrong.
[ November 05, 2007: Message edited by: sudhir nim ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65119
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instance variables, which shouldn't be used in the first place, will behave differently under those differing scenarios.

But what it all comes down to is that it is deprecated and should never be used.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic