//懒汉式,线程不安全
public class Singleton2 {private static Singleton2 singleton;private Singleton2(){}public static Singleton2 getInstance(){if(singleton == null){singleton = new Singleton2();}return singleton;}public static void main(String[] args) {Singleton2 instance1 = Singleton2.getInstance();Singleton2 instance2 = Singleton2.getInstance();System.out.println(instance1 == instance2);System.out.println("****");System.out.println(instance1.hashCode());System.out.println(instance2.hashCode());}
}