解答
正确答案是
class SingletonLazy {
private static SingletonLazy singletonLazy;
private SingletonLazy() {
}
public static SingletonLazy getInstance() {
try {
if (null == singletonLazy) {
// 模拟在创建对象之前做一些准备工作
Thread.sleep(1000);
synchronized (SingletonLazy.class) {
if(null == singletonLazy) {
singletonLazy = new SingletonLazy();
}
}
}
} catch (InterruptedException e) {
// TODO: handle exception
}
return singletonLazy;
}
}
在大学没有那么优秀的经历怎么办
起来更新了,老铁
收益匪浅啊