Introduction
This lesson gives an introduction to the problem of the thread-safe initialization of singletons, and how to solve it through various methods in C++.
Before we start with this case study, let me emphasize that I am not advocating the use of the singleton pattern; I only use it here because it is a classic example for a variable that must be initialized in a thread-safe way. For a more elaborate discussion about the pros and cons of the singleton pattern, please refer to the referenced articles in the Wikipedia page for the singleton pattern.
I want to start my discussion of the thread-safe initialization of the singleton pattern with a detour.
Get hands-on with 1400+ tech skills courses.