SpringMvc中Hashmap操作遇到 java.util.ConcurrentModificationException: null

代码按照网上修改为类似,还不能解决问题

for (Iterator<String> it = target.keySet().iterator(); it.hasNext(); ) {
  if(...)
   it.remove();
}

,后来根据异常名称,推测是在Servlet多线程环境下保持,换成并发ConcurrentHashMap就解决问题了。

参考:

HashMap报错:java.util.ConcurrentModificationException

猜你喜欢

转载自www.cnblogs.com/passedbylove/p/10386216.html