I have seen the classic singleton class in C++. My understanding is this implementation is thread safe. Then I read that if this class is included in 2 DLLs and both are loaded in 1 application, you will get 2 copies of static variable hence 2 instances of the S class, hence it is not exactly thread safe.
So the solution is still using a mutex lock? (I know this is common practice in C#, as detailed in : http://csharpindepth.com/Articles/General/Singleton.aspx
class S
{
public:
static S& getInstance()
{
static S instance;
return instance;
}
private:
S();
S(S const&); // Don't Implement
void operator=(S const&); // Don't implement
};