title: Why does this thread data race?
body: <p>I am new to threads and learning. Why does this data race? I know how to do it using the <code>Synchronized(){}</code> method but not with the modifier.</p>
  
  <pre><code>public class SyncMethodDataRace extends Thread {
  
      private static int common = 0;
  
      public synchronized void run(){
          int local = common;
          local++;
          common = local;
      }
  
  
      public static void main(String[] args) throws InterruptedException {
          SyncMethodDataRace[] allThreads = new SyncMethodDataRace[20000];
  
          for(int i = 0; i &lt; allThreads.length; i++){
              allThreads[i] = new SyncMethodDataRace();
          }
  
          for(SyncMethodDataRace d: allThreads){
              d.start();
          }
  
          for(SyncMethodDataRace d: allThreads){
              d.join();
          }
  
          System.out.println(common);
      }
  }
  </code></pre>