class="java"> 一、 public class Singleton { private Singleton() { }; private static Singleton single = new Singleton(); public static Singleton getInstance() { return single; } } 二、 public class Singleton { private Singleton() { }; private static Singleton single = null; public synchronized static Singleton getInstance() { if (single == null) { single = new Singleton(); } return single; } }