public class Sample { private volatile static Sample sample; public Sample(){ } public static Sample getInstance(){ if (sample == null){ synchronized (Sample.class){ if (sample == null){ sample = new Sample(); } } } return sample; } }