title: Java Memory Model and boolean for success
body: <p>I'm new to the Java threading and have only recently started to read up on the Memory Model. From my understanding the Java Memory Model as it stands allows the compiler to make optimizations. </p>
  
  <p>This can complicate multi-threaded code and synchronization but my question is for something much simpler. Take this example since the two statements are not dependent on each other, is it possible that the compiler could change the ordering of the code in the try statement and therefore break the check?</p>
  
  <pre><code>boolean success = false;
  try{
   MyClass.someFunction();
   success = true;
  }
  catch(Exception e){
  
  }
  
  if(success){    
      System.out.println("Sucess!");
  }
  else{
      System.out.println("Fail!");
  }
  </code></pre>