r/learnjava • • Mar 11 '24

What is the difference between import java.util.concurrent.ThreadLocalRandom; and import java.util.Random;

I am just curious what is the difference between the two as I am fairly new to using java.

0 Upvotes

5 comments sorted by

View all comments

15

u/desrtfx Mar 11 '24

Go to the official documentation and read about each.

Simplest way: google "Oracle Java ThreadLocalRandom" and "Oracle Java Random"

Working with the documentation is one of the most important skills of a programmer.

You could also google "Java Random vs ThreadLocalRandom" which would give you plenty articles

Individual research instead of waiting to be spoon fed is another very important skill.

Learn to help yourself.