vendredi 11 mars 2022

How does Initialization on demand holder Idiom ensures only "single" instance is created ever?

I went through the wiki https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom to understand Initialization on demand holder Idiom for Singleton pattern, though the wiki mentions how it's thread safe, it doesn't say how this actually ensures only one instance is created ever, i.e if in two different classes Something.getInstance() is called how do they have the same object ?

I am new to Java, so any help would be appreciated.

Aucun commentaire:

Enregistrer un commentaire