public class 单例模式 {
private static 单例模式 _share;
private static Object obj = new Object();
private 单例模式() {}
public static 单例模式 Share单例模式() {
if (_share == null)
{
lock (obj)
{
if (_share == null)
{
_share = new 单例模式();
}
}
}
return _share;
}
}
public class 单例模式1
{
private static 单例模式1 _share;
static 单例模式1() {
_share = new 单例模式1();
}
public static 单例模式1 Share() {
return _share;
}
}
单例模式
最新推荐文章于 2025-01-06 18:04:26 发布