title: why is static inner class singleton thread safe
body: <p>As the title said, why is static nested class singleton thread-safe?</p>
  
  <pre><code>public class Singleton {
      private static class SingletonHolder {
          public static Singleton instance;
  
          public static Singleton getInstance() {
              if (null == instance) {
                  instance = new Singleton();
              }
          }
      }
  
      public static Singleton getInstance() {
          return SingletonHolder.getInstance();
      }
  } 
  </code></pre>