This is an interview question.
In C++, for singleton design pattern, is it possible that there may be multiple instances of the class? If yes, in what cases?
My idea:
In multithreading cases, without synchronous protections, it is possible that we may have multiple instances generated by multiple threads.
We can use a mutex to do the protection. For example, use a mutex to protect a global variable as counter to keep the numbers of instances to assure that there is only one instance.
Any better ideas?