Lazy-loaded singleton: Double-checked locking vs Initialization on demand holder idiom
问题 I have a requirement to lazy-load resources in a concurrent environment. The code to load the resources should be executed only once. Both Double-checked locking (using JRE 5+ and the volatile keyword) and Initialization on demand holder idiom seems to fit the job well. Just by looking at the code, Initialization on demand holder idiom seems cleaner and more efficient (but hey, I'm guessing here). Still, I will have to take care and document the pattern at every one of my Singletons. At least