问题描述
此问题直接。我认为我的第二个问题的答案是否定的。所以我想了解为什么java.util.concurrent包中没有ConcurrentLinkedHashMap?我的意思是有一个ConcurrentHashMap,但没有ConcurrentLinkedHashMap。在并发环境中有这样一个课程是否没有任何意义?我的意思是这里的主要技术原因是不可用的?在Guava / Apache Commons中有类似的东西吗?
This question follows directly from my previous question here in SO . I think the answer to my second question is no . So I would like understand why there is no ConcurrentLinkedHashMap in java.util.concurrent package ? I mean there is a ConcurrentHashMap but no ConcurrentLinkedHashMap . Does it not make any sense at all to have such a class in Concurrent environments ? I mean what is the main technical reason here for its non availabalility ? Is there something similar in Guava/ Apache Commons ?
推荐答案
你需要问Oracle Java的人,但我想象它是一个组合:
You would need to ask the Oracle Java guys that, but I imagine it it is a combination of:
- 一种认为没有多少人需要它的感觉,而
- 在高度并发的用例中实现具有良好性能的数据结构的固有困难。
- a perception that not many people would need it, and
- the inherent difficulties in implementing data structures with good performance properties in highly concurrent use cases.
在这种情况下,在我看来,实现集合类,以便迭代键/值/条目集不是一个并发的瓶颈。 ..嗯...很难(即使人们想要做到这一点,事实仍然是,设计和实现和证明通用高度并发的数据结构和算法的正确性很困难。)
In this case, it seems to me that implementing the collection class so that iterating the key/value/entry sets is not a concurrency bottleneck would be ... um ... difficult. (And even if people have figured a way to do it, the fact remains that designing and implementing and proving the correctness of general purpose highly concurrent data structures and algorithms is hard.)
这篇关于为什么jdk中没有ConcurrentLinkedHashMap类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!