0

Suppose there is a function :

Obj* Obj::instance()
{
   static Obj obj;
   return &obj;
}

As we known that obj will be initialized when Obj::instance has been called for the first time. But what will happen if multiple thread call this function concurrently?

camino
  • 10,085
  • 20
  • 64
  • 115

1 Answers1

0

Thread with the highest priority gets a lock on that variable!

Mohanavel T
  • 371
  • 4
  • 17