java.util.HashMap 中的无限循环 [英] Infinite loop in java.util.HashMap

查看:29
本文介绍了java.util.HashMap 中的无限循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里经常遇到一些 Vaadin 代码阻塞,我不知道问题可能是什么:

I have some Vaadin code blocking very often here, and I have no idea what the problem can be:

Thread 7892: (state = IN_JAVA)
 - java.util.HashMap.getEntry(java.lang.Object) @bci=61, line=349 (Compiled frame; information may be imprecise)
 - java.util.HashMap.containsKey(java.lang.Object) @bci=2, line=335 (Compiled frame)
 - java.util.HashSet.contains(java.lang.Object) @bci=5, line=184 (Compiled frame)
 - com.vaadin.ui.Table.unregisterPropertiesAndComponents(java.util.HashSet, java.util.HashSet) @bci=85, line=1693 (Compiled frame)
 - com.vaadin.ui.Table.refreshRenderedCells() @bci=992, line=1641 (Compiled frame)
 - com.vaadin.ui.Table.valueChange(com.vaadin.data.Property$ValueChangeEvent) @bci=23, line=2897 (Compiled frame)
 - com.vaadin.data.util.IndexedContainer.firePropertyValueChange(com.vaadin.data.util.IndexedContainer$IndexedContainerProperty) @bci=140, line=553 (Compiled frame)
 - com.vaadin.data.util.IndexedContainer.access$1000(com.vaadin.data.util.IndexedContainer, com.vaadin.data.util.IndexedContainer$IndexedContainerProperty) @bci=2, line=64 (Compiled frame)
 - com.vaadin.data.util.IndexedContainer$IndexedContainerProperty.setValue(java.lang.Object) @bci=202, line=915 (Compiled frame)
 - com.aimprosoft.wavilon.backgroundthreads.ChangeCdrThread.insertNewPersonIntoTable(com.aimprosoft.wavilon.model.Person, com.vaadin.ui.HorizontalLayout, com.aimprosoft.wavilon.ui.menuitems.CallContent, com.vaadin.ui.Table) @bci=924, line=208 (Interpreted frame)
 - com.aimprosoft.wavilon.backgroundthreads.ChangeCdrThread$RepaintTableThread.run() @bci=622, line=446 (Compiled frame)

有人可以建议任何方法来进一步调试此问题吗?这个问题很少发生,而且很难重现.

Can somebody suggest any way to further debug this issue? The problem happens very rarely, and it is quite difficult to reproduce.

推荐答案

根据它在代码中的位置,我能想到的唯一解释是有多个线程访问和更新那个HashMap 没有正确同步.这可能会导致地图的数据结构损坏,并可能导致无限循环.

Based on where it is in the code, the only explanation I can think of is that there are multiple threads accessing and updating that HashMap without synchronizing properly. This can cause the map's data structures to be corrupted, and could result in an infinite loop.

我想不出 java.util.HashMap.getEntry 会阻塞的任何其他原因.它不做任何同步或任何 I/O.

I can't think of any other reason why java.util.HashMap.getEntry would block. It doesn't do any synchronization or any I/O.

Roland Illig 评论:

Roland Illig comments:

行号确实表明代码挂在 e = e.next 循环之一中.

The line number indeed suggests that the code hangs in one of the e = e.next loops.

这支持了我的假设.由两个(或更多)线程对哈希表执行的特定操作序列导致在其中一个哈希链中创建循环/循环.发生这种损坏是因为执行操作的线程之间没有充分的同步.这种事情很少发生,但一旦发生,腐败就不会消失.

That supports my hypothesis. A particular sequence of operations on the hash table performed by two (or more) threads has resulted in the creation of a loop / cycle in one of the hash chains. This corruption has happened because there was inadequate synchronization between the threads performing the operations. It is the kind of thing that happens very rarely, but once it has happened the corruption won't go away.

在没有深入研究 Vaadin 源代码的情况下,我无法准确告诉您它是 Vaadin 错误,还是您使用 Vaadin 方式的错误.任何一种解释都是合理的.

Without looking deeply into the Vaadin source code, I can't tell you exactly whether it is a Vaadin bug, or a bug in the way that you are using Vaadin. Either explanation is plausible.

更新

基于 这篇文章(在下面的评论中提供),我想说这很可能是您的应用程序同步(或不同步)方式的问题.

Based on this article (provided in a comment below), I would say that it is most likely a problem in the way that your application is synchronizing (or not).

这篇关于java.util.HashMap 中的无限循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆