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 ]
Joined: Mar 22, 2002
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
Joined: Mar 09, 2001
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.