[concurrency-interest] ConcurrentHashSet?

Roman Elizarov elizarov at devexperts.com
Fri Jul 31 10:40:35 EDT 2009

Hello Christian!

You can use Collections.newSetFromMap(new ConcurrentHashMap()).
There is no need to have a separate "ConcurrentHashSet" class, since
sets in java.util (like HashSet) are typically wrappers over
corresponding Map implementations.

Roman Elizarov

On Friday, July 31, 2009 6:17:18 PM you wrote:

CVH> I have on multiple occasions found myself wanting a ConcurrentHashSet
CVH> that is to ConcurrentHashMap as HashSet is to HashMap. Yet I find no
CVH> such class in java.util.concurrent.

CVH> Is this because ConcurrentSkipListSet and CopyOnWriteArraySet in
CVH> between them pretty much covers the ground for concurrent sets? I can
CVH> sort of intuit the performance pattern I can expect from
CVH> CopyOnWriteArraySet, but I an unsure about ConcurrentSkipListSet.
CVH> Also, I'm often not terribly interested in the contract that follows
CVH> use of a SortedSet.

More information about the Concurrency-interest mailing list