单例模式懒汉式
public class LazySingle {
private static LazySingle lazySingle = null;
private LazySingle(){
System.out.println("被创建"+UUID.randomUUID());
}
public static LazySingle getInstance(){
if (lazySingle == null) {
lazySingle = new LazySingle();
}
return lazySingle;
}
public static void main(String[] args) {
LazySingle l1 = LazySingle.getInstance();
LazySingle l2 = lazySingle.getInstance();
}