双重检测所的线程安全问题
双重检测所的线程安全问题解决方案
直接来看下面这段代码
public class StudentInstance{
private Student student;
public Student getInstance(){
if(student == null){
synchronized(this){
if(student == null){
student = new Student("xx",'19');
}
}
}
}
}
感觉好像没啥问题
主
原创
2021-08-06 14:32:29 ·
167 阅读 ·
0 评论