Why would somebody write a singleton like this (with volatile and synchronized)?
public class Singleton { private volatile static Singleton singleton; private Singleton(){} public static Singleton getInstance(){ if(singleton==null){ synchronized (Singleton.class){ if(singleton==null){ singleton = new Singleton(); } } } return singleton; } }