이이 정적 이유싱글 톤 클래스에서 인스턴스 멤버가 정적 인 이유는 무엇입니까?
public sealed class Singleton
{
static Singleton instance=null;
static readonly object padlock = new object();
Singleton()
{
}
public static Singleton Instance
{
get
{
lock (padlock)
{
if (instance==null)
{
instance = new Singleton();
}
return instance;
}
}
}
}
내 질문 static Singleton instance=null;
하는 싱글 톤 클래스?
이것은 특히 닷넷의 (현재) threadsafe, performant 싱글 톤 패턴과 같지 않습니다. (나는 그것이 패턴을위한 MSDN P & P 코드임을 깨닫는다.) See @JonSkeet http://csharpindepth.com/Articles/General/Singleton.aspx –
그렇지 않은 경우 싱글 톤이 아니기 때문입니다. –