title: Why instance variable in Servlet is not thread-safe
body: <p>When I read <code>Head First Servlet and JSP</code>, they say that instance variable is non-thread safe.</p>
  
  <p>I don't understand this statement so much. For example: I have a servlet which name is <code>ActionServlet.java</code>.  Each time, each user's request is sent to server, container will create a new thread and create new <code>ActionServlet</code> instance.</p>
  
  <p><code>ActionServlet</code> may be has a structure:</p>
  
  <pre><code>public class ActionServlet extends HttpServlet {
     // example of instance variable
     Instance variable;
     public void processRequest(HttpServletRequest request, HttpServletResponse response) {   
         // process something relating to instance variable
     }
  }
  </code></pre>
  
  <p>So, because all these threads create a new class instance for <code>ActionServlet</code>, so I don't see any problem here. because instances of these thread is separate of each other.</p>
  
  <p>Please figure out where problem when use instance variable in multithread environment.</p>
  
  <p>Thanks :) </p>