The answer to your question is mainly related to how class fields are initialized.
In the second example, the _instance field _instance initialized upon declaration. Each time a static field is initialized during the declaration, a static constructor is created (if you have not already declared it). At compile time, initialization will be transferred to the static constructor. This means that you will have something like this (did not copy the IL code, as it would be harder to understand):
public sealed class SingletonClass { [ThreadStatic] private static SingletonClass _instance; public static SingletonClass Instance { get { return _instance; } } static SingletonClass() { _instance = new SingletonClass(); } }
The CLR ensures that the static constructor is called only once, no matter how many threads you have. If you look at the code above, this means that for the two tasks created, the _instance field will be initialized only once (since there will be only one call for the static constructor).
source share