Most likely you came here because you know the
java.util.concurrent.ConcurrentHashMap class but couldn’t find
java.util.concurrent.ConcurrentHashSet. Sorry, this is not in the Java API yet.
The good news is that from Java 6 onwards the Collections API provides a method that allows one to obtain the
java.util.Set. Here it is: [code]java.util.Collections.newSetFromMap(Map
Let’s say you need a
Concurrent HashSet of Strings, just do the following:
[code language=’java’] Set<String> stringSet = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());