samedi 3 avril 2021

C++ Multithreading : Race condition in static variable Initialization [duplicate]

Is there any race condition when multiple threads execute below code ?

class test;
test& get_my_class_instance()
{
   static test instance; // static initialisation
   return instance;
}  

Is static initialisation above guaranteed to be thread safe?

Aucun commentaire:

Enregistrer un commentaire