title: Singleton & Multithreading in Java
body: <p>What is the preferred way to work with Singleton class in multithreaded environment?</p>
  
  <p>Suppose if I have 3 threads, and all of them try to access <code>getInstance()</code> method of singleton class at the same time - </p>
  
  <ol>
  <li>What would happen if no synchronization is maintained? </li>
  <li>Is it good practice to use <code>synchronized</code> <code>getInstance()</code> method or use <code>synchronized</code> block inside <code>getInstance()</code>. </li>
  </ol>
  
  <p>Please advise if there is any other way out.</p>