Source :
http://www.podar.net/cgi-bin/scwcd/answers.pl?question=33&correct=4&user=1 1. public class TestServlet extends HttpServlet implements SingleThreadModel {
2. private static int num = 5;
3. public void doGet(HttpServletRequest req, HttpServletResponse resp) {
4. // do nothing;
5. }
6. }
Is num variable
thread safe?
Explanation: Explanation though the class implements SingleThreadModel but since the variable declared is static ,there is still the risk that num is modified by multiple pool instances or multiple named instances simultaneously
I dont understand ? num should be thread safe, as there will be only one thread of this
servlet at a time.
[ August 08, 2008: Message edited by: Sunny Jain ]