singleton 싱글톤 패턴


singleton 싱글톤 패턴

https://bluayer.com/32 https://devmoony.tistory.com/43#:~:text=싱글톤 패턴이란%3F,위험이 생길 수 있다. ‘만약 중간에 해당 객체의 값이 바뀐다면, 다른 스레드에서도 잘 적용될 수 있는가?’ 와 같은 동시성 문제를 해결할 수 있어야 한다. class Simple { private static instance: Simple private a: number private constructor () { } // 메소드 이름은 달라도 상관없다. init(a: number) { this.a = a } // 메소드 이름은 달라도 상관없다. public static getInstance () { return this.instance || (this.instance = new this()) } }...



원문링크 : singleton 싱글톤 패턴