Singleton & Multi-threading
- by ronan
Friends
I have the following class that
class Singleton
{
private:
static Singleton *p_inst;
Singleton();
public:
static Singleton * instance()
{
if (!p_inst)
{
p_inst = new Singleton();
}
return p_inst;
}
};
Please do elaborate on precautions taken while implementing Singleton in multi-threaded environment ..
Many thanks