• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic