• 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

Is servlet singlethreaded or multithreaded

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks,
Is a servlet single threaded or multithreaded.one thread runs at a time in service() method.Right???
can anyone please clarify this.

thanks

sri
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi shanthisri,

By default, servlet is multithreaded unless you specify it through SingleThreadModel implemention or use isThreadSafe attribute for JSP (knowing that JSPs are turned into servlets).
 
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess current version of Servlet spec, SingleThradModel is deprecated. I am not sure. Please check the spec.
 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes .. SingleThreadModel is deprecated because there is nothing useful that we achieve from it.

If servlet A is implementing SingleThreadModel, then only one thread can be there for that servlet, at a time. But does this guarantee a thread safe application? What if Servlet B's thread modifies an attribute which servlet A is accessing.

Thats why this interface is useless and is deprecated too. It gives a wrong notion to programmers that implementing this interface guarantees thread-safeness. And HFSJ calls a person a poor servlet programmer if one uses SingleThreadModel.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic