如果字典不包含给定键的值,它将只返回false,还是由于线程竞争条件,它也将返回false,就像另一个线程添加/更新某些内容一样?
代码中的问题:
ConcurrentDictionary<int, string> cd = new ConcurrentDictionary<int, string>();
// This might fail if another thread is adding with key value of 1.
cd.TryAdd(1, "one");
// Will this ever fail if no other thread ever removes with the key value of 1?
cd.TryRemove(1);
Edit:个 我认为只有在不包含给定键的值的情况下,它才会返回false,但希望绝对确定.