Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibly replace ThreadLocalRandom #1749

Open
pjfanning opened this issue Jan 28, 2025 · 0 comments
Open

Possibly replace ThreadLocalRandom #1749

pjfanning opened this issue Jan 28, 2025 · 0 comments

Comments

@pjfanning
Copy link
Contributor

pjfanning commented Jan 28, 2025

ThreadLocalRandom may not be a great idea if you are using Virtual Threads (#611).

Java 17+ has a new RandomGenerator and we could allow users to choose via config which generator to use.

RandomGenerator random = RandomGenerator.of("L64X128MixRandom")

List of algorithms:
https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/random/package-summary.html#algorithms

We could have a centralised util function to get a generator. Java 8-16 users would get a ThreadLocalRandominstance when this functio was called. Java 17+ users - we could use Reflection or MethodHandles to create a generator based on config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant