exam1-java
双重检查锁的单例模式
public class Singleton {
private static volatile Singleton singleton;
private Singleton() {
}
public static Singleton getInstance() {
if (singleton == null) {
synchronized (Singleton.class) {
if (singleton == null) {
singleton = new Singleton();
}
}
}
return singleton;
}
}HashMap 取值 一个value有三个abc字符串
编译错误与运行时错误
选择题
Last updated
Was this helpful?