[9] RFR (XS): 8044730: small errors in ConcurrentHashMap and LongAdder docs
Hi Martin, Thanks for augmenting my patch and pushing it into the JSR166 repo. Here's the patch rebased against jdk9-dev. Please review. s'marks # HG changeset patch # User smarks # Date 1402960663 25200 # Mon Jun 16 16:17:43 2014 -0700 # Node ID c8c2d902f3f1338b8074607367e7af8e294ae1c6 # Parent ade4491b571e65f28a6295b8be9679830a5e9a85 8044730: small errors in ConcurrentHashMap and LongAdder docs Reviewed-by: XXX diff -r ade4491b571e -r c8c2d902f3f1 src/share/classes/java/util/concurrent/ConcurrentHashMap.java --- a/src/share/classes/java/util/concurrent/ConcurrentHashMap.java Mon Jun 16 13:48:58 2014 -0400 +++ b/src/share/classes/java/util/concurrent/ConcurrentHashMap.java Mon Jun 16 16:17:43 2014 -0700 @@ -133,12 +133,12 @@ * mapped values are (perhaps transiently) not used or all take the * same mapping value. * - * <p>A ConcurrentHashMap can be used as scalable frequency map (a + * <p>A ConcurrentHashMap can be used as a scalable frequency map (a * form of histogram or multiset) by using {@link * java.util.concurrent.atomic.LongAdder} values and initializing via * {@link #computeIfAbsent computeIfAbsent}. For example, to add a count * to a {@code ConcurrentHashMap<String,LongAdder> freqs}, you can use - * {@code freqs.computeIfAbsent(k -> new LongAdder()).increment();} + * {@code freqs.computeIfAbsent(key, k -> new LongAdder()).increment();} * * <p>This class and its views and iterators implement all of the * <em>optional</em> methods of the {@link Map} and {@link Iterator} diff -r ade4491b571e -r c8c2d902f3f1 src/share/classes/java/util/concurrent/atomic/LongAdder.java --- a/src/share/classes/java/util/concurrent/atomic/LongAdder.java Mon Jun 16 13:48:58 2014 -0400 +++ b/src/share/classes/java/util/concurrent/atomic/LongAdder.java Mon Jun 16 16:17:43 2014 -0700 @@ -57,7 +57,7 @@ * frequency map (a form of histogram or multiset). For example, to * add a count to a {@code ConcurrentHashMap<String,LongAdder> freqs}, * initializing if not already present, you can use {@code - * freqs.computeIfAbsent(k -> new LongAdder()).increment();} + * freqs.computeIfAbsent(key, k -> new LongAdder()).increment();} * * <p>This class extends {@link Number}, but does <em>not</em> define * methods such as {@code equals}, {@code hashCode} and {@code
Looks good! On Mon, Jun 16, 2014 at 4:52 PM, Stuart Marks <stuart.marks@oracle.com> wrote:
Hi Martin,
Thanks for augmenting my patch and pushing it into the JSR166 repo. Here's the patch rebased against jdk9-dev. Please review.
s'marks
# HG changeset patch # User smarks # Date 1402960663 25200 # Mon Jun 16 16:17:43 2014 -0700 # Node ID c8c2d902f3f1338b8074607367e7af8e294ae1c6 # Parent ade4491b571e65f28a6295b8be9679830a5e9a85 8044730: small errors in ConcurrentHashMap and LongAdder docs Reviewed-by: XXX
diff -r ade4491b571e -r c8c2d902f3f1 src/share/classes/java/util/ concurrent/ConcurrentHashMap.java --- a/src/share/classes/java/util/concurrent/ConcurrentHashMap.java Mon Jun 16 13:48:58 2014 -0400 +++ b/src/share/classes/java/util/concurrent/ConcurrentHashMap.java Mon Jun 16 16:17:43 2014 -0700 @@ -133,12 +133,12 @@ * mapped values are (perhaps transiently) not used or all take the * same mapping value. * - * <p>A ConcurrentHashMap can be used as scalable frequency map (a + * <p>A ConcurrentHashMap can be used as a scalable frequency map (a * form of histogram or multiset) by using {@link * java.util.concurrent.atomic.LongAdder} values and initializing via * {@link #computeIfAbsent computeIfAbsent}. For example, to add a count * to a {@code ConcurrentHashMap<String,LongAdder> freqs}, you can use - * {@code freqs.computeIfAbsent(k -> new LongAdder()).increment();} + * {@code freqs.computeIfAbsent(key, k -> new LongAdder()).increment();} * * <p>This class and its views and iterators implement all of the * <em>optional</em> methods of the {@link Map} and {@link Iterator} diff -r ade4491b571e -r c8c2d902f3f1 src/share/classes/java/util/ concurrent/atomic/LongAdder.java --- a/src/share/classes/java/util/concurrent/atomic/LongAdder.java Mon Jun 16 13:48:58 2014 -0400 +++ b/src/share/classes/java/util/concurrent/atomic/LongAdder.java Mon Jun 16 16:17:43 2014 -0700 @@ -57,7 +57,7 @@ * frequency map (a form of histogram or multiset). For example, to * add a count to a {@code ConcurrentHashMap<String,LongAdder> freqs}, * initializing if not already present, you can use {@code - * freqs.computeIfAbsent(k -> new LongAdder()).increment();} + * freqs.computeIfAbsent(key, k -> new LongAdder()).increment();} * * <p>This class extends {@link Number}, but does <em>not</em> define * methods such as {@code equals}, {@code hashCode} and {@code
participants (2)
-
Martin Buchholz
-
Stuart Marks