(no subject)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

(no subject)

JSR166 Concurrency mailing list
Hey folks 

Attempted to post this last week while I was joining the list. I think it bounced. Please ignore if it is a repeat. I have not seen any responses and I am sad.

I found some great discussion of a previous issue* with nested Stream.parallel operations here and hoping I might find some answers to a related question.

I am using a ConcurrentHashMap.compute operation in an outer Stream.parallel forEach operation. A library used in the compute method also uses Stream.parallel.

I have written a test that illustrates the issue and explores different implementations in 215 lines of code.

The code deadlocks with the following stack trace:

I do not understand why line 87 (the compute block) appears to be called recursively leading to deadlock when I use Stream.parallel for the outer loop.

Best

David

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|

Re: CHM.compute restrictions (was: no subject)

JSR166 Concurrency mailing list
On 08/06/2018 10:10 AM, David Stuebe via Concurrency-interest wrote:
> Hey folks 
>
> Attempted to post this last week while I was joining the list.

To reduce spam, non-member posts are silently dropped. Sorry.

>
> I am using a ConcurrentHashMap.compute operation in an outer
> Stream.parallel forEach operation. A library used in the compute method
> also uses Stream.parallel.
>
> I have written a test that illustrates the issue and explores different
> implementations in 215 lines of code.
> https://gist.github.com/dstuebe/89361f64dc44a935e53d0a49f149317c#file-nestedparallel-java
>
> The code deadlocks with the following stack trace:
> https://gist.github.com/dstuebe/89361f64dc44a935e53d0a49f149317c#file-stacktrace-txt
>
> I do not understand why line 87 (the compute block) appears to be called
> recursively leading to deadlock when I use Stream.parallel for the outer
> loop.

A recursive CHM.compute call appears to invoked while trying to
initialize the contents of an element in the same map, which is
disallowed in general, but sometimes works anyway. In most other cases,
CHM successfully detects this and throws an exception, but it cannot
catch all of them.

-Doug




_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest