Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC#the .NET memory modelSingle-choice MCQ

Two threads run this double-checked locking pattern. Even with the lock, why is marking `_instance` as the only volatile field still important on the .NET memory model?

if (_instance == null) { lock (_lock) { if (_instance == null) _instance = new Service(); } } return _instance;