[concurrency-interest] Locking a ConcurrentHashSet in a ConcurrentHasHMap
Thomas.Hawtin at Sun.COM
Thu Aug 7 10:13:38 EDT 2008
Mike Bean wrote:
> I was wondering if anyone had some thoughts on how to avoid a lock to
> allow removal of a ConcurrentHashSet from a ConcurrentHashMap. Context
> is an index manager with these two calls:
I guess you could use a doNotUse flag in a subclass of
ConcurrentHashSet. Set the flag before removing the set. Check the flag
after adding to it.
If only we had a standard full set of multiset collections and the like...
> I'm also concerned at the memory cost of a ConcurrentHashSet for a
> single reference to an Entry object but the indexing and unindexing
> entries gets more complex with the map containing an Entry or a
> ConcurrentHashSet of Entries.
Are you sure you are going to have significant contention given the map?
Perhaps a plain set with synchronisation would do. Or an immutable [by
More information about the Concurrency-interest