title: Thread safety for static variables
body: <pre><code>class ABC implements Runnable {
      private static int a;
      private static int b;
      public void run() {
      }
  }
  </code></pre>
  
  <p>I have a Java class as above. I have multiple threads of this class. In the <code>run()</code> method, the variables <code>a</code> &amp; <code>b</code> are incremented each for several times. On each increment, I am putting these variables in a Hashtable.</p>
  
  <p>Hence, each thread will increment both variables and putting them in Hashtable. How can I make these operations thread safe?</p>