Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state


 1、問題描述:

項目多線程運用了Dictionary報錯Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state

2、原因分析:

Dictionary被多個線程同時所修改導致的所措。

3、解決辦法:

Dictionary換成ConCurrentDictionary。

ConCurrentDictionary內部實現了鎖機制。不會報以上錯誤。如果要用Dictionary則需要自己加入鎖機制


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM