K
kiluyar
I have such a function:
class T
{
public:
T(){...//some operations}
};
T& GetInst()
{
static T t;
return t;
}
I'm not sure whether this is thread safe? If T's constructor has many
operations, when two thread entered this function early and later, is
there such scenario: the first thread is in T's constructor's, the
second thread define t again?
class T
{
public:
T(){...//some operations}
};
T& GetInst()
{
static T t;
return t;
}
I'm not sure whether this is thread safe? If T's constructor has many
operations, when two thread entered this function early and later, is
there such scenario: the first thread is in T's constructor's, the
second thread define t again?