System.Collections.Generic.Dictionary`2.Insert System.NullReferenceException

今天在單線程的時候C# dictionary插入數據,不會出現問題

在多線程的時候出現 System.Collections.Generic.Dictionary`2.Insert System.NullReferenceException: 未將對象引用設置到對象的實例

加一個鎖試試吧

Monitor.Enter(x);
。。。。。
Monitor.Exit(x);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章