• 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

Multithreaded service()

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if service() method of a typical servlet is multithreaded, which one of the following issues does not need to be address in the servlet's implementation?
Concurrent access to =>>shared resouces ?
local variables?static variables? instance variables?

thanks
[ April 01, 2002: Message edited by: Roland2k1 ]
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Access to shared resouces outside the servlet is a concern, even if you are implementing SingleThreadModel, because all that is guaranteed is that only one thread will execute the service() method at a time.
2. Local variables are as thread-safe as they can be, since each thread as its own "copy".
3. Static variables are not thread-safe, even if you implement SingleThreadModel, because the specs allow the container to create a pool of servlets.
4. Instance variables are not thread safe. Even though only one servlet instance (per servlet definition) services requests, concurrent requests will spawn threads that can access that servlet's instance variables.
You can check out more of the specs here. It's actually very readable and informative
-anthony
 
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roland2k1,
Your display name does not conform with the Javaranch naming policy. Please read this policy and change your display name if you wish to keep posting here. Thanks.
reply
    Bookmark Topic Watch Topic
  • New Topic