Way*_*oss 3 c# syntax multithreading locking
下面的_otherThing字段是否会被锁保护?
class ThreadSafeThing
{
private readonly object _sync = new object();
private SomeOtherThing _otherThing;
public SomeOtherThing OtherThing { get { lock(_sync) return _otherThing; } }
public void UpdateOtherThing(SomeOtherThing otherThing)
{
lock(_sync) _otherThing = otherThing;
}
}
Run Code Online (Sandbox Code Playgroud)