ThreadLocalRandom.nextGaussian() uses locking Random.nextGaussian() implementation

Alan Bateman alan.bateman at oracle.com
Wed Nov 19 07:44:25 UTC 2025



On 18/11/2025 17:44, James Yuzawa wrote:
> Hello,
>
> I have noticed in Java 25 (and earlier versions) that calling ThreadLocalRandom.current().nextGaussian() uses the Random.nextGaussian() implementation, which is synchronized. Under heavy load in a multithreaded environment, I was detecting lock contention.
>
>
I think this is a mistake that crept in with JEP 356 in JDK 17 and the 
follow up work. We need to create an issue in JBS to track this.

-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20251119/1371c9c7/attachment-0001.htm>


More information about the core-libs-dev mailing list