假设我的类中有两个方法,writeToMap()并且processKey()这两个方法都被多个线程调用。writeToMap是一种在 hashmap 中写入内容的方法,用于基于ofprocessKey()做某事。keySetHashMap
在 processKey 中,我首先originalMap在获取密钥集之前复制。
new HashMap<String, Map<String,String>(originalMap).get("xx").keySet();
ConcurrentModificationException但是即使我总是复制哈希图,我仍然会得到。有什么问题?