001package headfirst.singleton.threadsafe; 002 003public class Singleton { 004 private static Singleton uniqueInstance; 005 006 // other useful instance variables here 007 008 private Singleton() {} 009 010 public static synchronized Singleton getInstance() { 011 if (uniqueInstance == null) { 012 uniqueInstance = new Singleton(); 013 } 014 return uniqueInstance; 015 } 016 017 // other useful methods here 018}