diff --git a/src/main/java/dice/sinanya/tools/makedata/RandomInt.java b/src/main/java/dice/sinanya/tools/makedata/RandomInt.java index 0c2023bb69b2bcf4800515c8038dfe0bdfc50800..11105d54178b22e47e67a84e8f06ef5b3898cfe7 100644 --- a/src/main/java/dice/sinanya/tools/makedata/RandomInt.java +++ b/src/main/java/dice/sinanya/tools/makedata/RandomInt.java @@ -28,7 +28,11 @@ import static java.lang.Math.max; public class RandomInt { private static final Logger log = LogManager.getLogger(RandomInt.class.getName()); private static final Random r = new Random(); + private static final Random R_DEFAULT = new Random(r.nextLong()); + private static final MersenneTwister MERSENNE_WISTER = new MersenneTwister(r.nextLong()); + + private RandomInt() { throw new IllegalStateException("Utility class"); } @@ -100,13 +104,13 @@ public class RandomInt { } public static int randomDefault(int lowest, int highest) { - Random random = new Random(); - return random.nextInt(highest - lowest + 1) + lowest; +// Random random = new Random(); + return R_DEFAULT.nextInt(highest - lowest + 1) + lowest; } public static int randomMersenne(int lowest, int highest) { - MersenneTwister mersenneTwister = new MersenneTwister(randomDefault(0, 1000)); - return mersenneTwister.nextInt(highest - lowest + 1) + lowest; +// MersenneTwister mersenneTwister = new MersenneTwister(randomDefault(0, 1000)); + return MERSENNE_WISTER.nextInt(highest - lowest + 1) + lowest; }