harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellison <t.p.elli...@gmail.com>
Subject Re: [jira] Created: (HARMONY-6404) possible data-reordering in some hashCode-methods (e.g. String or URL)
Date Fri, 11 Dec 2009 10:11:06 GMT
On 11/Dec/2009 04:09, Vijay Menon wrote:
> Perhaps I'm missing some context, but I don't see any problem.  I don't
> believe that this:
> 
>         if (hashCode == 0) {
>             // calculate hash
>             hashCode = hash;
>         }
>         return hashCode;
> 
> can ever return 0 (assuming hash is non-zero), regardless of memory fences.
>  The JMM won't allow visible reordering in a single threaded program.

I agree.  In the multi-threaded case there can be a data race on the
hashCode, with the effect that the same hashCode value is unnecessarily,
but harmlessly, recalculated.

Regards,
Tim

Mime
View raw message