List of utility methods to do ThreadLocalRandom
String | getRandomValue(String prefix, long maxValue) get Random Value long randomLongValue = ThreadLocalRandom.current().nextLong(maxValue); return prefix + randomLongValue; |
String | getTempPersistFileName(String baseFileName) get Temp Persist File Name return baseFileName + "." + ThreadLocalRandom.current().nextLong(Long.MAX_VALUE); |
ThreadLocalRandom | getThreadLocalRandom() get Thread Local Random return ThreadLocalRandom.current();
|
boolean | isRandomOccurrence(int pcLikelihood) is Random Occurrence if (pcLikelihood < 0 || pcLikelihood > 100) { throw new IllegalArgumentException(); int pc = ThreadLocalRandom.current().nextInt(100 + 1); return (pc > 0 && pc <= pcLikelihood); |
double[] | moveInRadius(double[] position, double radius) move In Radius double[] newPosition = new double[position.length]; for (int i = 0; i < position.length; i++) { newPosition[i] = position[i] + ThreadLocalRandom.current().nextDouble(-radius, radius); return newPosition; |
long | parseSeed(String seedString) parse Seed if (seedString == null || seedString.length() == 0) return ThreadLocalRandom.current().nextLong(); try { long j = Long.parseLong(seedString); if (j == 0L) throw new IllegalArgumentException("Zero (0) isn't a valid seed."); return j; } catch (NumberFormatException numberformatexception) { ... |
E | rand(final Collection rand if (items.isEmpty()) { throw new IllegalArgumentException("Can't pick an item from zero items."); final int rand = ThreadLocalRandom.current().nextInt(items.size()); int i = 0; E result = null; for (final E item : items) { if (i == rand) { ... |
int | randInt(int min, int max) Returns a pseudo-random number between min and max, inclusive. Random rand = ThreadLocalRandom.current(); int randomNum = rand.nextInt((max - min) + 1) + min; return randomNum; |
String | random() random String str = ""; for (int i = 0; i < 20; i++) { str += String.valueOf((ThreadLocalRandom.current().nextInt(0, 9))); return str; |
Random | random() random return ThreadLocalRandom.current();
|