This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Synchronization using SingleThread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Synchronization using SingleThread" Watch "Synchronization using SingleThread" New topic
Author

Synchronization using SingleThread

Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1844

what is the advantage of using the SingleThreadModel interface rather than using the synchronized keyword before the service method.

Advance Thanx.


Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 400+ OCPJP Mock Questions
Gayan Balasooriya
Ranch Hand

Joined: Jul 31, 2002
Posts: 51
If your servlet implements the SingleThreadModel interface, servlet container may create several instances of the servlet to process different requests.If you synchronize the service method, all the requests will be processed one by one from a single instance of the servlet.
Gayan Balasooriya
SCJP2,SCWCD
http://www.gayanb.com - Developer Resources
[ September 04, 2003: Message edited by: Gayan Balasooriya ]

SCJP, SCWCD
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12758
    
    5
If your design requires either of those techniques, you need to redesign your application to properly make use of the servlet API. In my opinion, SingleThreadModel was a mistake in the first place - it is expected to be deprecated in the near future.
Bill
 
 
subject: Synchronization using SingleThread
 
Similar Threads
how to
Loading an image
file access within package
Comments on Jetspeed, Slide, Velocity, Turbine ?
unable to internalize message