class MySingleton
{
private volatile static MySingleton instance=null;
private MySingleton() {}
public static MySingleton getInstance()
{
if(instance==null)
{
synchronized(MySingleton.class)
{
if(instance==null)
{
instance=new MySingleton();
return instance;
}
}
}
return instance;
}
}
JAVA:DCL单例
最新推荐文章于 2023-04-12 13:54:27 发布