CONCURRENT SET
Hello,
Is there any concurrent implementation of HashSet?
CopyOnWriteArraySet is not useful for me (I'll have a lot of threads reading and writing on this set)
And ConcurrentSkipListSet keeps the order of the elements, and for me the order is not important (as a normal set).
And I wouldn't want to use a Collections.synchronizedSet(...), because of too much locking.
Any alternative?
Thanks.
# 2
If you don't want any of the standard solutions, what are your special locking needs? Chances are you will need to implement your own locking scheme.
BTW, are you sure Collections.concurrentSet() won't do? Have you profiled a solution based on that and concluded that its locking is slowing your application down?
# 3
Hello,
Yes, I've made test cases not with Set but with ConcurrentHashMap and Hashtable/Collections.synchronizedMap(). With hundreds of threads getting/putting in these collections (as my app does), the behaivour of ConcurrentHashMap is much better than the other solutions.
That's why I thought that with Collections.synchronizedSet against any concurrent implementation of Set the conclusion would be the same.
But as Caffeine says, I can try with ConcurrentHashMap asking for the key and ignoring the value.
Thanks.