On 08/22/2013 03:37 AM, Brian Burkhalter wrote:
> With respect to this issue
>
> http://bugs.sun.com/view_bug.do?bug_id=6470700
>
> the code of concern from java.lang.Math is
>
> 701private static Random randomNumberGenerator;
> 702
> 703private static synchronized Random initRNG() {
> 7
On Aug 21 2013, at 17:01 , David M. Lloyd wrote:
> On 8/21/13 5:37 PM, Brian Burkhalter wrote:
>> With respect to this issue
>>
>> http://bugs.sun.com/view_bug.do?bug_id=6470700
>>
>> the code of concern from java.lang.Math is
>>
>> 701private static Random randomNumberGenerator;
>> 702
>>
There's a significant difference here: Random reads the field into a local
and then operates only on the local. Looking at the code, I only see one
possible (bizarre) circumstance where you can hit NPE. If code was
transformed to:
static double random() {
Random rnd = randomNumberGenerator
On Aug 21, 2013, at 4:37 PM, Brian Burkhalter
wrote:
> With respect to this issue
>
> http://bugs.sun.com/view_bug.do?bug_id=6470700
>
> the code of concern from java.lang.Math is
>
> 701private static Random randomNumberGenerator;
> 702
> 703private static synchronized Random initRN
On Aug 21, 2013, at 5:01 PM, David M. Lloyd wrote:
> I don't think you'd want to introduce the overhead of synchronization here.
No, I don't. My example code was just that.
> It may be better in this case to use this kind of lazy init pattern:
>
>static final class Holder {
>static
On 8/21/13 5:37 PM, Brian Burkhalter wrote:
With respect to this issue
http://bugs.sun.com/view_bug.do?bug_id=6470700
the code of concern from java.lang.Math is
701private static Random randomNumberGenerator;
702
703private static synchronized Random initRNG() {
704Random rnd =