Re: Concurrency question?
On 07.02.2015 07:29, Kevin McMurtrie wrote:
In article <54ce6897$0$289$14726298@news.sunsite.dk>,
Arne Vajh=C3=B8j <arne@vajhoej.dk> wrote:
On 2/1/2015 1:59 AM, Kevin McMurtrie wrote:
I don't recommend ConcurrentHashMap EVER unless you need atomic
conditional updates. The implementation is expensive and it's still =
not
entirely lock free. You need a lot of concurrency from a lot CPU cor=
es
before you'll see it outperform the old Hashtable class.
That is not my experience. CHM seems to be as fast or faster than Ht
in most cases I have seen.
size(), isEmpty(), and toArray() are slower and must allocate temporary=
objects. get() and put() can be comparable in speed to HashMap, minus
some overhead for the internal sharding used to reduce lock scope.
But then it is entirely dependent on the use case whether one or the
other is faster (well, no surprises here). That is quite a different
statement than the one you made above which gave the impression that CHM =
is only better in some arcane special cases with "a lot of concurrency".
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/