Forums Register Login

SingleThread Model

+Pie Number of slices to send: Send
What is SingleThread Model?
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
 

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.

 
+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
It's not irrelevant, it's the API.
+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
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.
and POOF! You're gone! But look, this tiny ad is still here:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 898 times.
Similar Threads
Is Servlet SingleThread Model or Multithread Model by default?
singlethreadmodel
singlethreadmodel
Shared Access
This Weeks GiveAway:
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:30:26.