ThreadLocalRandom, SecureRandm, java.util.Random, java.math.Random

Instances of java.util.Random are threadsafe. However, the concurrent use of the same java.util.Random instance across threads may encounter contention and consequent poor performance. Consider instead using ThreadLocalRandom in multithreaded designs.

The Java Math library function Math.random() generates a double value in the range [0,1). Notice this range does not include the 1.

int rand = ThreadLocalRandom.current().nextInt(x,y);