[concurrency-interest] ConcurrentHashMapV8

Doug Lea dl at cs.oswego.edu
Mon Aug 29 19:43:37 EDT 2011


On 08/29/11 13:52, Bob Lee wrote:
> On Mon, Aug 29, 2011 at 10:37 AM, Doug Lea <dl at cs.oswego.edu
> <mailto:dl at cs.oswego.edu>> wrote:
>
>         It wasn't obvious to me how recursive computations are handled for the same
>         key and appears to livelock. This is an error condition that used to
>         deadlocked MapMaker. I fixed this by failing fast if Thread.holdsLock() was
>         true prior to waiting for the computation to finish.
>
>
>     I'm not sure I follow. If the user function in turn calls computeIfAbsent
>     for the same key, then it seems irreparably broken in the same sense as,
>     for example. a user's equals() function that attempts to invoke map.put.
>
>
> It is irreparably broken, but it's an easy and common mistake to make. It's
> difficult to identify the problem when the program just deadlocks vs. throwing
> an explicit exception that identifies the at fault key.
>

Well, in CHMV8. it won't deadlock, but instead gets into
an infinite loop (a form livelock), which makes it a more
marginal call whether to place a check that is not cheap
along a common path. But I'm tentatively planning to put it
in to next update anyway.

-Doug


More information about the Concurrency-interest mailing list