在此链接中,我找到了如下的单例实例化:
public static Singleton getInstanceDC() {
if (_instance == null) { // Single Checked (1)
synchronized (Singleton.class) {
if (_instance == null) { // Double checked
_instance = new Singleton();
}
}
}
return _instance;
}
我没有得到单次检查的意义,即 (1) 。它在这里有什么用,单线程将检查同步块内的实例,那么使用第一次检查有什么意义呢?