wood burning stoves 2.0*
The moose likes Servlets and the fly likes When to use SingleThreadModel? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "When to use SingleThreadModel?" Watch "When to use SingleThreadModel?" New topic
Author

When to use SingleThreadModel?

Dez Max
Ranch Hand

Joined: Oct 01, 2002
Posts: 41
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

Joined: Jun 18, 2001
Posts: 351
I too am waiting for this answer. A business requirement which forces us to go for a SingleThreadModel !

Thanks and Regards,
Leena


[SCJP2, SCWCD1.3, SCBCD]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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

Joined: Mar 06, 2001
Posts: 13459

"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
 
 
subject: When to use SingleThreadModel?