Safe Publication and Safe Initialization in Java
shipilev.net
shipilev.net
> 3. It is lazy. One can argue about this, but non-lazy factories are not interesting for our discussion. Singleton initialization should happen with the first request for a Singleton, not when Singleton class is initialized. If no one wants a Singleton instance, we should not instantiate it.
I wish Java had a one-true-way for one-time static initialization like dispatch_once() in Objective-C.