RFR 8173083: VarHandle usages in LockSupport and ThreadLocalRandom result in circularity issues
Martin Buchholz
martinrb at google.com
Fri Jan 20 17:54:11 UTC 2017
> (r = (long) SEED.get(t)) + GAMMA);
=>
r = ((long) SEED.get(t)) + GAMMA);
or I think you can just leave them out
r = (long) SEED.get(t) + GAMMA);
On Fri, Jan 20, 2017 at 9:48 AM, Paul Sandoz <paul.sandoz at oracle.com> wrote:
>
> On 20 Jan 2017, at 09:45, Martin Buchholz <martinrb at google.com> wrote:
>
>
>
> On Fri, Jan 20, 2017 at 7:58 AM, Paul Sandoz <paul.sandoz at oracle.com>
> wrote:
>
>>
>> I was surprised to see below a change in parentheses that seems to change
>> the behavior.
>>
>> final long nextSeed() {
>> Thread t; long r; // read and update per-thread seed
>> - SEED.set(t = Thread.currentThread(),
>> - (r = (long) SEED.get(t)) + GAMMA);
>> + U.putLong(t = Thread.currentThread(), SEED,
>> + r = U.getLong(t, SEED) + GAMMA);
>> return r;
>> }
>>
>>
>> The update reverted to the previous code:
>>
>> http://hg.openjdk.java.net/jdk9/dev/jdk/file/7901a13a051c/
>> src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java
>>
>> I added the parentheses to bound the cast.
>>
>
> It still looks to me like the parenthesis got added to the wrong place (in
> the previous changeset!),
>
>
> What place do you think they should be?
>
> Paul.
>
More information about the core-libs-dev
mailing list