aspose file tools
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 Groovy Fundamentals video training course this week in the Groovy 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: 1847

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

Advance Thanx.


Krishna Srinivasan
OCAJP 7/8 Exam, 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: 12955
    
    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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Synchronization using SingleThread