Java 8 introduced new way to obtain a concurrent Set
implementation
// Pre-Java-8 way to create a concurrent set
Set oldStyle = Collec
ConcurrentHashMap.newKeySet()
should be somewhat more efficient as removes a single level of indirection. Collections.newSetFromMap(map)
is mostly based on redirecting the operations to the map.keySet()
, but ConcurrentHashMap.newKeySet()
is very close to map.keySet()
itself (just with additions support).
As for functionality, I see no difference.