當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。