• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Is MyServlet Thread Safe

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If MyServlet implements singleThreadModel, I read some where that I Can say that MyServlet is Thread safe, But what happens when the multiple instances are created by the servlet container. Shouldn't the methods of MyServlet be synchronized to make sure that MyServlet is Thread Safe.
Thanks in Advance
 
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Krupa,
Implementing SingleModeThread does not guarantee the servlet to be thread-safe, as the container may create multiple instances of the servlet class to process multiple requests.
 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Implementing SingleThreadModel interface only guarantees that no two threads will execute service() method on the same instance. Everything else like static variables(not thread safe), session scope, context scope etc. is developer's pain and he has to take care of it.
 
reply
    Bookmark Topic Watch Topic
  • New Topic