Bill Pugh 솔루션이 Thread Safe 한 이유
get Instance를 호출해야 내부 Holder 클래스가 처음 접근 되고 런타임에 동적으로 로딩됨
Class를 로딩하고 초기화하는 시점은 thread-safe를 보장함
→ 클래스 로딩이 Single Thread 인 것은 아님 ClassLoader 내부의 Parallel Loader 클래스를 사용 멀티 쓰레드 안정성을 보장
//inner static class 활용 class Singleton { private Singleton() {} private static class SingletonHolder { private static final Singleton INSTANCE = new Singleton(); } public static Singleton getInstance() { return SingletonHolder.Instance; } }