title: Why is this code not thread safe?
body: <p>In code snippet below, declaring the doThings() method as static would make the class thread-safe. Is the reason for this that if multiple TestSeven threads are started and since x is a static variable a race condition could occur ?</p>
  
  <pre><code>public class TestSeven extends Thread{
  
      private static int x;
  
      public synchronized void doThings(){
          int current = x;
          current++;
          x = current;
      }
  
      public void run(){
          doThings();
      }
  
      public static void main(String args[]){
          TestSeven t = new TestSeven();
          Thread thread = new Thread(t);
          thread.start();
      }
  }
  </code></pre>