A particular seed will always produce the same sequence of "random" numbers. Thus, in Random there are only 2 ^ 64 different sequences. In addition to setSeed you can also use a constructor with a seed. When not in use, a seed uses a computer clock to select a truly random seed.
Therefore, in the normal case, do not use a specific seed, the Random() constructor, and no setSeed . Especially refrain from setSeed(System.currentTimeMillis()) .
For a data-dependent debug where you want to repeat the same pseudo-random data, use a specific seed.
No need to worry about whether a particular seed / sequence and subsequent digits can be recognized due to the large number of seeds.
The default constructor uses System.nanoTime() (correctly distorted), which is an expensive OS function when it comes to thousands of new Random() .
source share