자바에서 스레드 안전을 지키는 방법 (https://developer-ellen.tistory.com/205)

* Mutual Exclusion

* Atomic Operation

* Using thread-local

* Re-Entrancy

 

VarHandle (https://countryxide.tistory.com/88)

 

자바에서 싱글톤 만들기 (https://simyeju.tistory.com/121)

1. eager initialization : 객체 안에 private static으로 만들기

2. lazy initialization : getInstance호출시 if로 널체크하고 만들기 (not safe)

3. lazy initialization + synchronized : syncrhonized블럭으로 동기화 (too heavy)

4. double check locking : getInstance할때 null이면 synchronized로 동기화시키고 널체크 한번더 (메모리 공간 할당만 했는데 다른 스레드에서 null체크를 하면 오동작 할수도. not safe)

5. lazy init + holder : private static final로 인스턴스를 가지고있는 홀더객체를 따로만듬 (safe, recommended)

+ Recent posts