title: get unexpected values using synchronize
body: <p>I have a simple snippet of code and try to experiment a little with it, but in the next code I get unclear for me order of output data:</p>
  
  <pre><code>public class Main {
  
      static int n = 100;
  
      public static synchronized int decreaseValue(){
          return --n;
      }
  
      public static void main(String[] args) throws InterruptedException, IOException {
  
  
          Thread t1 = new Thread(new Runnable() {
              @Override
              public void run() {
                  while(true){
                      try {
                          System.out.println("Thread1: "+ decreaseValue());
                          Thread.sleep(2000);
                      } catch (InterruptedException e) {
                          e.printStackTrace();
                      }
                  }
              }
          },"Thread1");
          t1.start(); 
  
          Thread t2 = new Thread(new Runnable() {
              @Override
              public void run() {
                  while(true){
                      try {
                          System.out.println("Thread2: "+ decreaseValue());
                          Thread.sleep(2000);
                      } catch (InterruptedException e) {
                          e.printStackTrace();
                      }
                  }
              }
          },"Thread2");
          t2.start();
  
  
          while(true){
              try {
                  System.out.println("Main Thread: "+ decreaseValue());
                  Thread.sleep(2000);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
          }
      }
  }
  </code></pre>
  
  <p>Can not understand, why I get the such values in the next order:</p>
  
  <p>Thread1: 89
          Thread2: 90
          Main Thread: 88</p>
  
  <p>PLEASE PAY ATTENTION TO THE N VALUE NOT TO THE ORDER OF CALLING THREADS:</p>
  
  <pre><code>Thread1: 99
  Thread2: 98
  Main Thread: 97
  Main Thread: 95
  Thread2: 94
  Thread1: 96
  Main Thread: 92
  </code></pre>