15,446
社区成员




T* GetInstance()
{
static T* pInst = new T;
return pInst;
}
volatile T* pInst = 0;
T* GetInstance()
{
if(pInst == NULL)
{
lock();
if(pInst == NULL)
pInst = new T;
unlock();
}
return pInst;
}
相对于直接lock高效.
volatile T* pInst = 0;
T* GetInstance()
{
// if(pInst == NULL)
{
lock();
if(pInst == NULL)
pInst = new T;
unlock();
}
return pInst;
}