Stephan van Hulst wrote:
First off, it's simply bad design. Objects shouldn't be expensive to construct, and even if they are, there's probably no reason to keep them around in a static field.
I think the original argument was that synchronization was expensive. And avoiding it completely after the object has been constructed was a benefit.
The problem with the argument is many fold. First, it's not a reasonable use case. Yes, if you call the method a billion times, you may notice that the unsynchronized version may be faster... but is anyone going to seriously make a billion calls to a get a singleton in a back to back fashion? Second, synchronization has improved over the years. And synchronization of an uncontended lock has dramatically been improved... making it even less noticeable.
Henry