SyncHashtable 中真的线程安全吗?
查看源码:
[Serializable]
private class SyncHashtable : Hashtable
{
。。。
public override object this[object key]
{
get
{
return this._table[key];
}
set
{
lock (this._table.SyncRoot)
{
this._table[key] = value;
}
}
}
。。。
}
这是系统源码,明显这里就不线程安全(this._table[key] = value;非原子操作),我读书少,那为高手给扫扫盲?万分感谢!