Re: Potential data race in java.util.concurrent.ConcurrentHashMap at the fields TreeNode.left and right
Kasper Nielsen via Concurrency-interest <[email protected]> Thu, 26 Mar 2020 08:35:34 +0000
| Newsgroups | gmane.comp.java.jsr.166-concurrency |
|---|---|
| Message-ID | <CAPs6151odCx4xpLXh5Ff1-gyY6bZZ=wvOLD34HU97qQ5NNGQEA@mail.gmail.com> |
> I think there is a data race in the class java.util.concurrent.ConcurrentHashMap. > When reading from the fields TreeNode.left and TreeNode.right using get and writing to those fields using put those fields are not synchronized. > I think they both should be volatile similar to the field next of the class Node. All the fields in TreeNode are only read/written while synchronizing on the TreeBin they belong to. See, for example, http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/ConcurrentHashMap.java?revision=1.323&view=markup#l1902 Normal /Kasper _______________________________________________ Concurrency-interest mailing list [email protected] http://cs.oswego.edu/mailman/listinfo/concurrency-interest