On 09/03/2013 07:52 PM, Brian Burkhalter wrote:
On Sep 3, 2013, at 4:46 PM, Doug Lea wrote:

I assume you mean to change line 898:

       if (rnd == null) {
           rnd = ThreadLocalRandom.current();; // was: getSecureRandom();
       }

Yes.

This seems fine in terms of sufficient RNG quality and better
performance. Also in terns of being for sure thread-safe
even though it uses no locks/sync: there are no possible async
or parallel calls from entry into this method, so using
thread-local one is fine.

Thanks for the comments. One question I have is whether this change would still
be needed if

public boolean isProbablePrime(int certainty, Random rnd) {}

were added.


It would not be necessary, since passesMillerRabin is only called
from isProbablePrime, which would then use non-null argument.

Only adding isProbablePrime seems to be an OK conservative
move: no existing usages would be affected, but users would
need to somehow be told that they could improve performance
by changing their code to use the new method with
ThreadLocalRandom.current() as argument.

-Doug

Reply via email to