title: Java static variable updates
body: <p>Below you can see a static variable <code>counter</code> in a Java class.</p>
  
  <p>The question is when will this variable reset? For example, when I restart the program, computer. What are the other possible scenarios it can reset?</p>
  
  <p>Another question is: what could be the reasons for this variable to increase by less than the number of times the function do() is executed? For example, could it be something with starting multiple processes of the class <code>java Whatever</code>? Or could it be something with multiple threads/servers, etc?</p>
  
  <pre><code>class Whatever {
  
      static int counter = 0;
  
      function do() {
          counter++;
          //...
      }
  
  }
  </code></pre>
  
  <p>Additional question: If multiple threads execute function do(), how will the counter variable behave? It will be less than the number of times function do() was executed?</p>