java.lang.reflect.Module.WeakSet is not thread-safe
Rémi Forax
forax at univ-mlv.fr
Thu Apr 21 19:52:53 UTC 2016
I remember seeing this codd an thinking that synchronized should do the job.
I don't believe this use case requires something more complex.
Remi
Le 21 avril 2016 18:21:55 CEST, Alan Bateman <Alan.Bateman at oracle.com> a écrit :
>
>
>On 21/04/2016 17:07, Peter Levart wrote:
>> :
>>
>> ...while this seems OK from 1st look, it is not. WeakHashMap is not
>> thread-safe even for seemingly read-only operations. All its
>> operations can mutate internal state in a non-thread-safe way. The
>> simplest way to fix this is to use a writeLock for containsKey
>> operation too. But such structure does not scale well to multiple
>> threads for frequent lookups.
>Sigh, it's a left over from early prototyping and was meant to be
>replaced (but wasn't). Now seems the right time.
>
>-Alan
More information about the jigsaw-dev
mailing list