title: Java: Count with two Threads
body: <p>Suppose threads A and B are running the <code>next</code> function in the following Java code:</p>
  
  <pre><code>class Test
  {
      int sum=0;
  
      void next()
      {
          for(int i=0;i&lt;100;i++)
              sum++;
      }
  }
  </code></pre>
  
  <p>What might be the value of <code>sum</code> when both threads finish running next?
  My answer was 100-200. However, I am missing some case.</p>
  
  <p>Is there a scenario where the value of sum is less than 100?</p>