- Exercise
In this lesson, we'll solve an exercise related to thread-safe initialization.
We'll cover the following
Problem statement
The classical implementation of the singleton pattern in the given code is not thread-safe.
- Use the function
std::call_once
in combination with thestd::once_flag
to makeMySingleton
class thread-safe.
Get hands-on with 1400+ tech skills courses.