Singleton pattern - Does early binding (with static variables involved) diminish the need of mutex locks?
c++, design-patterns, java, singleton, thread-safety
Solution
I think they are referring to creating the Singleton instance before starting/creating any threads, thus alleviating the need for synchronization at creation.
EDIT: adding info about C++ and static variables
In C++, static variables are also initialized before execution like David Harkness mentions for Java. One issue with this in C++ can be in embedded environments where calls to malloc/new cant be performed until after the system is initialized, in which case using a Singleton static initializer could be problematic.
Problem
They say that early binding solves the problem of synchronization. I couldn't understand "how". Is this something special to Java or the same applies to C++ too? so, with this method we actually won't require a mutex lock?