In interviews there is always the Singleton question, I personally refuse to answer it on interview. The reason is very simple I don’t code singletons anymore. I use my IoC Container to provide me with a singleton. Sorry if you dont know what an IoC (Inversion of Control Container) is, then you are still in the old ages of coding.
For once and for all here is the hand written code of a singleton in multi-thread environment.
|
1 2 3 4 5 6 7 8 9 |




