One of the colleague suggested this approach of writing thread-safe code for creating singleton objects.
Class Singleton
{
Class Inner{
static Singleton instance = new Singleton();
}
Singleton getInstance()
{
return Inner.instance;
}
};
Class Singleton
{
Class Inner{
static Singleton instance = new Singleton();
}
Singleton getInstance()
{
return Inner.instance;
}
};
No comments:
Post a Comment