package com.wdf;
public class Singleton {
private volatile static Singleton singleton = null;
private Singleton() {
}
public static Singleton getInstance() {
if (singleton == null) {
synchronized (Singleton.class) {
//double checked locking
if (singleton == null) {
singleton = new Singleton();
}
}
}
return singleton;
}
}
单例模式
最新推荐文章于 2025-06-23 15:45:56 发布