Is Meyers' implementation of the Singleton pattern thread safe?

前端 未结 6 956
我寻月下人不归
我寻月下人不归 2020-11-22 04:55

Is the following implementation, using lazy initialization, of Singleton (Meyers\' Singleton) thread safe?

static Singleton& instance()
{
           


        
6条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 05:07

    The correct answer depends on your compiler. It can decide to make it threadsafe; it's not "naturallly" threadsafe.

提交回复
热议问题