Is this non-locked TryGetValue() dictionary access thread-safe?

前端 未结 3 821
囚心锁ツ
囚心锁ツ 2020-12-31 07:14
private object lockObj = new object();

private Dictionary dict = new Dictionary();

public string GetOrAddFromDict(int key)
{
         


        
3条回答
  •  长发绾君心
    2020-12-31 07:58

    Sadly, no.

    I carry around a custom HashMap that has this property.

    The defect is in the rehash() function.

提交回复
热议问题