concurrent sets (original) (raw)

Remi Forax forax at univ-mlv.fr
Sat Jan 12 05:40:28 PST 2013


On 01/12/2013 02:13 PM, Doug Lea wrote:

I'm still working on lambda-related tie-ins for j.u.c stuff (mostly Spliterators). As mentioned before, we will supply two explicitly concurrent Sets, both via static factory methods: ConcurrentHashMap.newKeySet, and ConcurrentSkipListMap.newKeySet. (The CSLM one gives Sorted/Navigable Set) These are necessary when people need/want parallel collect-into operations for sets. But how will they know to do this?

they don't need if they use methods Collector.to*

the implicit way: stream.parallel(). ... .collect(Collector.toSet()); // use a concurrent hash set stream.parallell(). ... .collect(Collector.toSortedSet()); // use a concurrent skip list set

the explicit way: Set<...> set = ConcurrentHashMap.newKeySet(); stream.parallel(). ... .forEach(set::add); SortedSet<...> sortedSet = ConcurrentSkipListMap.newKeySet(); stream.parallell(). ... .forEach(sortedSet::add);

The explicit way can be written is the javadoc of newKeyset() as an example of use.

-Doug

Rémi



More information about the lambda-libs-spec-observers mailing list