- 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 the std::once_flag to make MySingleton class thread-safe.

Get hands-on with 1000+ tech skills courses.