3 ms·
If you really need a lazy Java singleton for some reason, letting the classloader construct it (guaranteed to happen at most once, and as late as possible) is e
by prodigal_erik 16y ago
If you really need a lazy Java singleton for some reason, letting the classloader construct it (guaranteed to happen at most once, and as late as possible) is effortless and more robust than screwing around with the synchronization yourself. On the other hand, interviewing candidates has so shaken my faith that I'd be very impressed to meet anyone who knew this.
http://en.wikipedia.org/wiki/Singleton_pattern#The_solution_of_Bill_Pugh http://en.wikipedia.org/wiki/Singleton_pattern#The_solution_...
- javabuddy 16y agoAgree, Singleton loaded by Classloader is most robust way of doing it but they I just think why people discovered double check locking pattern for creating singleton instance ?