简体   繁体   English

如何跟踪哪个HashMap抛出ConcurrentModificationException

[英]How to trace which HashMap throws ConcurrentModificationException

In my application I have several HashMaps. 在我的应用程序中,我有几个HashMaps。 One of them do throw ConcurrentModificationException every now and then. 其中之一确实不时抛出ConcurrentModificationException。 Problem is that I do not know how to trace which Map actually throws it, and when the ConcurrentModification happens. 问题是我不知道如何跟踪实际上哪个Map抛出了Map,以及何时发生ConcurrentModification。 The stack trace does not show any line numbers to where it happens. 堆栈跟踪不会显示任何行号。 The begin of the stack trace looks liks this: 堆栈跟踪的开始看起来像这样:

java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:806)
at java.util.HashMap$ValueIterator.next(HashMap.java:838)
at com.parse.ParseTraverser.traverseInternal(ParseTraverser.java:87)
at com.parse.ParseTraverser.traverse(ParseTraverser.java:137)
at com.parse.ParseObject.collectFetchedObjects(ParseObject.java:817)
at com.parse.ParseObject.access$700(ParseObject.java:49)
at com.parse.ParseObject$13.then(ParseObject.java:1487)
at com.parse.ParseObject$13.then(ParseObject.java:1484)
at bolts.Task$15.run(Task.java:917)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
at bolts.Task.completeAfterTask(Task.java:908)
at bolts.Task.continueWithTask(Task.java:715)

如果您不能评估通过两个操作同时修改了哪个HashMap (经典示例是循环中的删除),则可以始终使用ConcurrentHashMap

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 HashMap中的ConcurrentModificationException - ConcurrentModificationException in HashMap 如何在避免ConcurrentModificationException的同时迭代HashMap - How to iterate over a HashMap while avoiding ConcurrentModificationException 如何在没有ConcurrentModificationException的情况下删除哈希图中的多个映射? - How to remove multiple mappings in hashmap without ConcurrentModificationException? Java HashMap中的ConcurrentModificationException程序 - ConcurrentModificationException Program in java HashMap 在HashMap中澄清@ConcurrentModificationException - Clarification @ConcurrentModificationException in HashMap java中的并发修改异常哈希图 - concurrentmodificationexception hashmap in java 为什么在 HashMap 中出现 ConcurrentModificationException - Why getting ConcurrentModificationException in HashMap 如何在并发线程中操作`values()`和`put()`时避免使用HashMap“ConcurrentModificationException”? - How to avoid HashMap “ConcurrentModificationException” while manipulating `values()` and `put()` in concurrent threads? 如何在迭代Hashmap时获取ConcurrentModificationException? - How I can get ConcurrentModificationException while iterating Hashmap? 如果在下面的代码片段中都抛出ConcurrentModificationException,则Hashtable和HashMap有什么区别? - What is the difference between Hashtable and HashMap if both throws ConcurrentModificationException in following code snippet?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM