ReSharper
 
Get ReSharper
You are viewing the documentation for an earlier version of ReSharper.

Code Inspection: Possible incorrect implementation of Double-Check Locking pattern. Possible multiple write access to checked field

Last modified: 21 July 2022

Consider the following piece of code:

Given the above code, writes that initialize the Foo instance could be delayed until the write of the instance value, thus creating the possibility that the instance returns an object in an uninitialized state.

In order to avoid this, the instance value must be made volatile.