Hi all
I have a doubt with singleton class
Usually we all declare a singleton class as following only
Can any one tell me other possibilities of creating singleton class?
Problem with an above approach is instance is static variable
If two threads hits my getInstance() method at the same time, same sec
Then I will have two instances for sure…
So what’s the best way to create
thread safe singleton class?
Another point is I hate to use the
word ‘synchronized’ directly
Their should be some approach available?