Skip to content

Commit 8097641

Browse files
committed
Remove redundant static ThreadLocalRandom field in RandomElementUtil.
1 parent b98389a commit 8097641

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
package com.eternalcode.commons;
22

3-
import com.eternalcode.commons.scheduler.Scheduler;
43
import java.util.Collection;
54
import java.util.Optional;
65
import java.util.concurrent.ThreadLocalRandom;
76

87
public class RandomElementUtil {
98

10-
private static final ThreadLocalRandom RANDOM = ThreadLocalRandom.current();
11-
129
private RandomElementUtil() {
1310
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
1411
}
@@ -19,7 +16,7 @@ public static <T> Optional<T> randomElement(Collection<T> collection) {
1916
}
2017

2118
return collection.stream()
22-
.skip(RANDOM.nextInt(collection.size()))
23-
.findFirst();
19+
.skip(ThreadLocalRandom.current().nextInt(collection.size()))
20+
.findFirst();
2421
}
2522
}

0 commit comments

Comments
 (0)