Guys,
I need to write thread safe singleton class for my assignment. below is the code snippet for factory method in singleton class, I will appreciate if anyone is having suggestion for the same.
*MySingleton * MySingleton::GetInstance()
{
if (m_pOnlyOneInstance == NULL)
{
pthread_mutex_lock(&mutex);
m_pOnlyOneInstance = new MySingleton();
pthread_mutex_unlock(&mutex);
}
return m_pOnlyOneInstance;
}