title: Safe Publication of Java object after calling setter on the object
body: <p>Will calling a setter after constructor execution but before returning the reference will be a safe publication ?</p>
  
  <pre><code>public class SafePublication {
      private int i = 0;
      private SafePublication() {
              i = 10;
      }
  
      // Here we are calling setter are object creation. 
      //Will this change be visible to other threads
     public static SafePublication getInstance() {
             SafePublication pub = new SafePublication();
             pub.setVal(20);
             return pub;
     }
  
     private void setVal(int x) {
             this.i = x;
     }
  }
  </code></pre>