C#에서 싱글톤 구현할 때

public class CommonUtil
{

    private static CommonUtil instance;

    private CommonUtil() { }

    public static CommonUtil Instance
    {
        get
        {
            lock(syncRoot)  // 멀티스레드에서 원자 상태를 유지하기 위해
            {
               if (instance == null)
               {
                   instance = new CommonUtil();
                }
            }
            return instance;
        }
    }
}




'LivePhoto개발' 카테고리의 다른 글

C# HMAC-SHA1 암호화  (2) 2010.11.09
C# Byte <-> String 문자열 변환  (0) 2010.11.09
환경설정 주의사항  (0) 2010.11.05
플러그인 프로젝트 세팅 순서  (0) 2010.11.05
라이브포토 기본 실행순서  (0) 2010.11.05

+ Recent posts