【发布时间】:2011-11-18 13:12:27
【问题描述】:
如果我有一个
Dictionary<int, StreamReader> myDic = new Dictionary<int, StreamReader>
//Populate dictionary
一个线程做
myDic[0] = new StreamReader(path);
另一个线程做
myDic[1] = new StreamReader(otherpath)
这个线程安全吗,因为字典中被修改的实际项目与另一个线程上的不同,或者我会得到一个InvalidOperationException: Collection was modified
【问题讨论】:
标签: c# .net multithreading .net-4.0