当前位置: 首页>>代码示例>>Java>>正文


Java ThreadLocalRandom.nextDouble方法代码示例

本文整理汇总了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) {}
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:ThreadLocalRandomTest.java

示例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();
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:15,代码来源:EntitySheep.java

示例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();
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:15,代码来源:EntitySheep.java

示例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);
	}
}
 
开发者ID:InsightEdge,项目名称:geospatial-catastrophe-modeling,代码行数:13,代码来源:Factory.java

示例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);
    }
}
 
开发者ID:burmanm,项目名称:compression-int,代码行数:11,代码来源:Simple8EncodeTest.java

示例6: getLat

import java.util.concurrent.ThreadLocalRandom; //导入方法依赖的package包/类
private static double getLat(ThreadLocalRandom random) {
    return random.nextDouble(-90, 90);
}
 
开发者ID:RWTH-i5-IDSG,项目名称:xsharing-services-router,代码行数:4,代码来源:DistanceCalcBenchmark.java

示例7: getLong

import java.util.concurrent.ThreadLocalRandom; //导入方法依赖的package包/类
private static double getLong(ThreadLocalRandom random) {
    return random.nextDouble(-180, 180);
}
 
开发者ID:RWTH-i5-IDSG,项目名称:xsharing-services-router,代码行数:4,代码来源:DistanceCalcBenchmark.java


注:本文中的java.util.concurrent.ThreadLocalRandom.nextDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。