【发布时间】:2009-08-14 06:55:44
【问题描述】:
下面的 _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;
}
}
【问题讨论】:
标签: c# multithreading syntax locking