• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SingleThreaded+synchronized

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to replace SingleThreaded model with synchronized keyword in
service method?
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rakesh Sahadevan:
Is it possible to replace SingleThreaded model with synchronized keyword in service method?

Yes. Is it a good idea? No. If you implement the (deprecated) SingleThreadModel, the container will create as many instances of the servlet as needed to handle the load. If you simply synchronize the service() method, you get just one instance, which might well become a bottleneck under high loads.

- Peter
 
Rakesh Sahadevan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya peter. you are correct.Actually its an interview question!!!
Yes. Is it a good idea? No. If you implement the (deprecated) SingleThreadModel, the container will create as many instances of the servlet as needed to handle the load. If you simply synchronize the service() method, you get just one instance, which might well become a bottleneck under high loads.
Thank u
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic