Re: Removing a layer of synchronization on Math.random

2010-06-05 Thread Doug Lea
> Here's an optimization for Math.random() that appears to be safe, > despite the double-check access: > It is just barely safe because of Random internals that preclude reordering of the field ref assignment. It would be nicer (and no slower) to put a Fences.orderWrites() here. Assuming we add Fe

Re: Removing a layer of synchronization on Math.random

2010-06-05 Thread Eamonn McManus
It seems to me that if two threads call this Math.random() at the same time then two instances of Random() can be constructed. That contradicts the specification of the method, and is theoretically observable because the two values from Math.random() will typically not be a pair of values that

Re: Removing a layer of synchronization on Math.random

2010-06-05 Thread Martin Buchholz
Thanks to all the reviewers who were too polite to say: """What was Martin thinking?""" For some reason I had imagined that Math.random() was itself synchronized. After editing, I have a very small change that is hardly worth doing except that I already have a webrev. http://cr.openjdk.java.net