List of utility methods to do ThreadLocalRandom
int | getRandomInt(int limit) get Random Int return RANDOM.nextInt(limit);
|
int | getRandomInt(int n) get Random Int return getThreadLocalRandom().nextInt(n);
|
int | getRandomInt(int r) Provide random numbers return ThreadLocalRandom.current().nextInt(r);
|
Integer | getRandomInteger() get Random Integer return ThreadLocalRandom.current().nextInt(1, 1000);
|
Integer | getRandomIntegerElement(List get Random Integer Element Integer selectedElement = null; if (list != null && !list.isEmpty()) { int listSize = list.size(); int randomIndex = ThreadLocalRandom.current().nextInt(0, listSize); selectedElement = list.get(randomIndex); return selectedElement; |
List | getRandomNumbers(Integer startNumber, Integer endNumber, Integer pageSize, Integer numNumbers) get Random Numbers Set<Integer> integers = new HashSet<>(); int maxNumbers = (endNumber - startNumber) / pageSize; if (numNumbers > maxNumbers) { numNumbers = maxNumbers; while (integers.size() < numNumbers) { int i = ThreadLocalRandom.current().nextInt(startNumber, endNumber + 1); i = (i / pageSize) * pageSize; ... |
String | getRandomPassword() get Random Password Random random = ThreadLocalRandom.current(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < 5 + random.nextInt(15); i++) { char c = chars[random.nextInt(chars.length)]; sb.append(c); return sb.toString(); |
String | getRandomStr(int len) get Random Str StringBuffer sb = new StringBuffer(); for (int i = 0; i < len; i++) { int num = ThreadLocalRandom.current().nextInt(10); sb.append(num); return sb.toString(); |
String | getRandomString(int length) get Random String return getRandomString(length, ThreadLocalRandom.current());
|
T | getRandomTarget(List get Random Target int randomIndex = ThreadLocalRandom.current().nextInt(targets.size()); return targets.get(randomIndex); |