How to synchronize a global object between two threads in C++?
I have two threads, thread A and thread B, and a global object stored in a unique_ptr
. Thread A initializes the object once, and thread B is designed to access the object only after the initialization is done. Here is my code: