问题描述
前一段时间,。
这很奇怪。我原本期望以下两种中的任何一种:
This is weird. I would have expected any of the following two:
- 工作原理
- 它会抛出
ConcurrentModificationException
- It works
- It throws a
ConcurrentModificationException
但是从不停止?这似乎很危险。这是一个错误吗?或者我是否误解了一些合同?
But just never halting? That seems dangerous. Is it a bug? Or did I misunderstand some contract?
推荐答案
这在。
在,我在代码审查期间发现了这个问题。 JavaDoc已更新,并添加了临时修复程序。由于性能问题,它被进一步删除。
In the 2011 proposal, I identified this issue during the code review. The JavaDoc was updated and a temporary fix was added. It was removed in a further rewrite due to performance issues.
在,我们探索了更好地检测和失败的方法。请注意,有些讨论是针对私人电子邮件进行的,以便考虑低级别的更改。虽然不是每个案例都可以涵盖,但常见案例不会活锁。这些在Doug的存储库中,但尚未进入JDK版本。
In the 2014 discussion, we explored ways to better detect and fail. Note that some of the discussion was taken offline to private email for considering the low-level changes. While not every case can be covered, the common cases will not livelock. These fixes are in Doug's repository but have not made it into a JDK release.
这篇关于递归ConcurrentHashMap.computeIfAbsent()调用永远不会终止。错误或“功能”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!