Thursday, 3 April 2014

Singleton without synchronization block in Java - thread safe approach

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;
}
};

No comments:

Post a Comment

AWS Data Pipeline Services

https://www.youtube.com/watch?v=tykcCf-Zz1M