Singleton double-check concurrency issue
Returning null is not the issue. The issue is that the new instance may be in a partially constructed state as perceived by another thread. Consider this declaration of Foo. class Foo { public int variable1; public int variable2; public Foo() { variable1 = 1; variable2 = 2; } } Here is how the code … Read more