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
JavaRanch » Java Forums » Java » Servlets
Bookmark "Synchronization using SingleThread" Watch "Synchronization using SingleThread" New topic

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 - Developer Resources
[ September 04, 2003: Message edited by: Gayan Balasooriya ]

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12889
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.
jQuery in Action, 2nd edition
subject: Synchronization using SingleThread