100218: BigInteger staticRandom field

David Holmes david.holmes at oracle.com
Fri Dec 16 04:38:43 UTC 2011

On 15/12/2011 7:45 AM, Paul Ciprich wrote:
> I've created a bug report to address a scalability problem with
> BigInteger's staticRandom field. The problem is that the shared
> staticRandom field causes bottlenecks with parallel code. The proposed
> solution is to change the staticRandom field to a ThreadLocal and eliminate
> the bottleneck by giving each thread its own copy of the SecureRandom
> object. Bug 100218 contains a patch with the proposed change if it is
> deemed acceptable.

As I wrote in the bug report:

If multiple threads pound on probablePrime then the shared random 
instance may indeed become a bottleneck. The performance implications of 
switching to a Thread-local instance needs to be given due consideration 
for the uncontended case.

Also you need to consider the lifetime of these Thread-local Random 
instances as with the current proposal they will remain live for the 
lifetime of the thread.


David Holmes

More information about the core-libs-dev mailing list