Netflix/ribbon

Double-Checked Locking

QiAnXinCodeSafe opened this issue · 0 comments

if (client == null){
synchronized (lock) {
client = namedClientMap.get(name);
if (client == null){

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.