lock블럭1 [개발더미][Unity] 모노 싱글톤 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Singleton : MonoBehaviour where T : MonoBehaviour { private static object lockObject = new object(); // 쓰레드 안전화에 사용 private static bool isQuit = false; // 프로그램이 종료되거나 이상이 있는 경우 판단 private static T instance = null; // 객체 public static T Instance { // 쓰레드 안전화(Thread-Safe) get { // lock블럭 : 한번에 한 쓰레드만 실행되도록 .. 2023. 7. 25. 이전 1 다음