本文整理汇总了Java中java.util.concurrent.ThreadLocalRandom.nextDouble方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadLocalRandom.nextDouble方法的具体用法?Java ThreadLocalRandom.nextDouble怎么用?Java ThreadLocalRandom.nextDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.ThreadLocalRandom
的用法示例。
在下文中一共展示了ThreadLocalRandom.nextDouble方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNextDoubleBoundNonPositive
import java.util.concurrent.ThreadLocalRandom; //导入方法依赖的package包/类
/**
* nextDouble(non-positive) throws IllegalArgumentException
*/
public void testNextDoubleBoundNonPositive() {
ThreadLocalRandom rnd = ThreadLocalRandom.current();
double[] badBounds = {
0.0d,
-17.0d,
-Double.MIN_VALUE,
Double.NEGATIVE_INFINITY,
Double.NaN,
};
for (double bound : badBounds) {
try {
rnd.nextDouble(bound);
shouldThrow();
} catch (IllegalArgumentException success) {}
}
}
示例2: randomColor
import java.util.concurrent.ThreadLocalRandom; //导入方法依赖的package包/类
private int randomColor() {
ThreadLocalRandom random = ThreadLocalRandom.current();
double rand = random.nextDouble(1, 100);
if (rand <= 0.164) {
return DyeColor.PINK.getWoolData();
}
if (rand <= 15) {
return random.nextBoolean() ? DyeColor.BLACK.getWoolData() : random.nextBoolean() ? DyeColor.GRAY.getWoolData() : DyeColor.LIGHT_GRAY.getWoolData();
}
return DyeColor.WHITE.getWoolData();
}
示例3: randomColor
import java.util.concurrent.ThreadLocalRandom; //导入方法依赖的package包/类
private int randomColor() {
ThreadLocalRandom random = ThreadLocalRandom.current();
double rand = random.nextDouble(1, 100);
if (rand <= 0.164) {
return DyeColor.PINK.getDyedData();
}
if (rand <= 15) {
return random.nextBoolean() ? DyeColor.BLACK.getDyedData() : random.nextBoolean() ? DyeColor.GRAY.getDyedData() : DyeColor.LIGHT_GRAY.getDyedData();
}
return DyeColor.WHITE.getDyedData();
}
示例4: createRandomPointWithinBounds
import java.util.concurrent.ThreadLocalRandom; //导入方法依赖的package包/类
private static Point createRandomPointWithinBounds(double xLat, double yLong, double radius) throws ParseException {
ThreadLocalRandom random = ThreadLocalRandom.current();
double x = random.nextDouble(xLat - radius, xLat + radius);
double y = random.nextDouble(yLong - radius, yLong + radius);
if (PointInPolygonHelper.getInstance().isPointInPolygon(x, y)) {
return ShapeFactory.point(x, y);
} else {
return createRandomPointWithinBounds(xLat, yLong, radius);
}
}
示例5: correctnessTesting
import java.util.concurrent.ThreadLocalRandom; //导入方法依赖的package包/类
@Test
void correctnessTesting() throws Exception {
ThreadLocalRandom random = ThreadLocalRandom.current();
for(int i = 0; i < 20; i++) {
ZipfDistribution zipf = new ZipfDistribution(random.nextDouble(), 1000);
long[] original = zipf.stream().limit(2000).asLongStream().toArray();
verifyCompression(original, -1);
}
}
示例6: getLat
import java.util.concurrent.ThreadLocalRandom; //导入方法依赖的package包/类
private static double getLat(ThreadLocalRandom random) {
return random.nextDouble(-90, 90);
}
示例7: getLong
import java.util.concurrent.ThreadLocalRandom; //导入方法依赖的package包/类
private static double getLong(ThreadLocalRandom random) {
return random.nextDouble(-180, 180);
}