Thread safety with Dictionary in .Net

后端 未结 4 1435
盖世英雄少女心
盖世英雄少女心 2020-12-19 03:15

I have this function:

static Dictionary KeyValueDictionary = new Dictionary();
static void IncreaseValue(int keyId, int adj         


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-19 04:22

    It's not thread safe, but does not check and so probably doesn't notice silent corruption.

    It will appear to be thread safe for a long time because only when it needs to rehash() does it have even a chance of exception. Otherwise, it just corrupts data.

提交回复
热议问题