java.util.concurrent.ThreadLocalRandom#longs ( )源码实例Demo

下面列出了java.util.concurrent.ThreadLocalRandom#longs ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-jdk9   文件: ThreadLocalRandom8Test.java
/**
 * Invoking sized ints, long, doubles, with negative sizes throws
 * IllegalArgumentException
 */
public void testBadStreamSize() {
    ThreadLocalRandom r = ThreadLocalRandom.current();
    Runnable[] throwingActions = {
        () -> r.ints(-1L),
        () -> r.ints(-1L, 2, 3),
        () -> r.longs(-1L),
        () -> r.longs(-1L, -1L, 1L),
        () -> r.doubles(-1L),
        () -> r.doubles(-1L, .5, .6),
    };
    assertThrows(IllegalArgumentException.class, throwingActions);
}
 
源代码2 项目: openjdk-jdk9   文件: ThreadLocalRandom8Test.java
/**
 * Invoking bounded ints, long, doubles, with illegal bounds throws
 * IllegalArgumentException
 */
public void testBadStreamBounds() {
    ThreadLocalRandom r = ThreadLocalRandom.current();
    Runnable[] throwingActions = {
        () -> r.ints(2, 1),
        () -> r.ints(10, 42, 42),
        () -> r.longs(-1L, -1L),
        () -> r.longs(10, 1L, -2L),
        () -> r.doubles(0.0, 0.0),
        () -> r.doubles(10, .5, .4),
    };
    assertThrows(IllegalArgumentException.class, throwingActions);
}
 
源代码3 项目: j2objc   文件: ThreadLocalRandom8Test.java
/**
 * Invoking sized ints, long, doubles, with negative sizes throws
 * IllegalArgumentException
 */
public void testBadStreamSize() {
    ThreadLocalRandom r = ThreadLocalRandom.current();
    Runnable[] throwingActions = {
        () -> r.ints(-1L),
        () -> r.ints(-1L, 2, 3),
        () -> r.longs(-1L),
        () -> r.longs(-1L, -1L, 1L),
        () -> r.doubles(-1L),
        () -> r.doubles(-1L, .5, .6),
    };
    assertThrows(IllegalArgumentException.class, throwingActions);
}
 
源代码4 项目: j2objc   文件: ThreadLocalRandom8Test.java
/**
 * Invoking bounded ints, long, doubles, with illegal bounds throws
 * IllegalArgumentException
 */
public void testBadStreamBounds() {
    ThreadLocalRandom r = ThreadLocalRandom.current();
    Runnable[] throwingActions = {
        () -> r.ints(2, 1),
        () -> r.ints(10, 42, 42),
        () -> r.longs(-1L, -1L),
        () -> r.longs(10, 1L, -2L),
        () -> r.doubles(0.0, 0.0),
        () -> r.doubles(10, .5, .4),
    };
    assertThrows(IllegalArgumentException.class, throwingActions);
}