本文整理匯總了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);
}