File tree Expand file tree Collapse file tree 1 file changed +2
-5
lines changed
eternalcode-commons-shared/src/main/java/com/eternalcode/commons Expand file tree Collapse file tree 1 file changed +2
-5
lines changed Original file line number Diff line number Diff line change 11package com .eternalcode .commons ;
22
3- import com .eternalcode .commons .scheduler .Scheduler ;
43import java .util .Collection ;
54import java .util .Optional ;
65import java .util .concurrent .ThreadLocalRandom ;
76
87public 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}
You can’t perform that action at this time.
0 commit comments