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
  • 9,449
  • 19
  • 60
  • 105

1 Answers1

0

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

Mohanavel T
  • 373
  • 3
  • 17