Skip to content

Commit a8ce779

Browse files
committed
Make random variable initialized only once
1 parent 15201f3 commit a8ce779

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

api/src/main/java/parallelmc/parallelutils/util/RandomTools.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@
77
*/
88
public class RandomTools {
99

10+
private static Random r;
11+
12+
private RandomTools() {
13+
r = new Random();
14+
}
15+
1016
/**
1117
* Calculates a random integer between two integer values
1218
* @param low The first integer
1319
* @param high The second integer
1420
* @return The random integer between low and high, inclusive
1521
*/
1622
public static int betweenTwoNumbers(int low, int high) {
17-
Random r = new Random();
1823
return r.nextInt(high - low + 1) + low;
1924
}
2025
}

0 commit comments

Comments
 (0)