singleton Double-Checked-Locking AND Initialization-on-demand

Double-Checked Locking is widely cited and used as an efficient method for implementing lazy initialization in a multithreaded environment. Unfortunately, it will not work reliably in a platform independent way when implemented in Java, without additional synchronization. When implemented in other languages, such as C++, it depends on the memory model of the processor, the…

Using Spring Beans from Non-Spring Classes

The idea is to have some static field holds the references like: The class would look like: Now you can use the spring service in any class just by calling ServiceReferenceHolder.1stService.whateverMethod();