微软官方的Singleton双锁算法。
2010-01-13 11:38
155 查看
http://msdn.microsoft.com/en-us/library/ms998558.aspx
Codeusing System;
public sealed class Singleton
{
private static volatile Singleton instance;
private static object syncRoot = new Object();
private Singleton() {}
public static Singleton Instance
{
get
{
if (instance == null)
{
lock (syncRoot)
{
if (instance == null)
instance = new Singleton();
}
}
return instance;
}
}
}
Codeusing System;
public sealed class Singleton
{
private static volatile Singleton instance;
private static object syncRoot = new Object();
private Singleton() {}
public static Singleton Instance
{
get
{
if (instance == null)
{
lock (syncRoot)
{
if (instance == null)
instance = new Singleton();
}
}
return instance;
}
}
}
相关文章推荐
- 微软官方Singleton双锁算法
- 微软官方的Visual Studio 控件命名规范
- 微软vs2012(visual Studio 2012)官方旗舰版下载地址
- VS2010中文版微软官方下载
- SQLServer 2008 下载地址(微软官方网站)
- 张力完成了“微软官方认证 Hyper-V 咨询工程师证书认证课程”的学习
- 微软官方工具推荐:Microsoft SQL Server 2008 R2 BPA
- 【caffe-Windows】微软官方caffe之 Python接口配置及图片生成实例
- Vista RC1微软官方下载地址
- C# 汉语生成拼音(微软官方方案)
- 微软官方的SqlHelper
- Windows XP Embedded (XPE)开发工具、升级包、中文包等微软官方下载地址
- Visual Studio 2008 Professional Edition(简体中文版,微软官方下载,3.7G)
- F:/QQDownload/Windows XP pro with sp3 VOL 微软官方(MSDN)简体中文版 + 正版密钥
- 微软官方:SELECT语句逻辑处理顺序
- ANI鼠标指针漏洞 微软官方补丁更新
- ControlTemplate Examples 微软官方模版例子
- 微软office产品官方博客
- 微软提升关机速度程序 v1.0 官方