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