How to write a Singleton (3/5)

In two previous posts I have tried to convince you not to implement the Singleton at all and to give up implementing it with lazy initialisation. Today I show how to write a singleton that uses lazy initialization. The presented code is one of 3 possible versions – the most readable one. Others will be [...]

Why synchronize? Go ATOMIC!

It is surprising how many useful classes can be found in java.util that are not commonly known to general public. Every now and then I stumble upon a class that has the functionality I have been implementing over and over my myself and today I will tell you about one of them: have you ever [...]

How to write a Singleton? (1/5)

It seems that Singleton from all design patterns is the most controversial one and people have drastically different views on whether or not it is useful. Many think it is in fact an antipattern and it does more harm than good. Personally I am not a big fan of singletons and it seems to me [...]