在多线程环境下使用hashMap时,用了迭代器进行迭代操作,并在其中进行了remove方法,抛出了异常
Exception in thread "main" java.util.ConcurrentModificationException
解决方法就是:用conCurrentHashMap来代替hashMap。因为它是线程安全的。
另外,感谢这篇文章:https://blog.csdn.net/qq_30051139/article/details/54019515
在多线程环境下使用hashMap时,用了迭代器进行迭代操作,并在其中进行了remove方法,抛出了异常
Exception in thread "main" java.util.ConcurrentModificationException
解决方法就是:用conCurrentHashMap来代替hashMap。因为它是线程安全的。
另外,感谢这篇文章:https://blog.csdn.net/qq_30051139/article/details/54019515