标签:ar ef new as return c class public oc
class SourceManager
{
private SourceManager() { }
private static SourceManager sourceManager;
public static SourceManager Instance
{
get
{
if (sourceManager == null)
{
/*
lock 实现方式
功能与以下 Interlocked.CompareExchange 相同
lock (this)
{
if (sourceManager == null)
{
sourceManager = new SourceManager();
}
}
*/
Interlocked.CompareExchange<SourceManager>(ref sourceManager, new SourceManager(), null);
}
return sourceManager;
}
}
}
标签:ar ef new as return c class public oc
原文地址:http://www.cnblogs.com/wolf12/p/4072483.html