本文整理匯總了Java中java.util.concurrent.ThreadLocalRandom.longs方法的典型用法代碼示例。如果您正苦於以下問題:Java ThreadLocalRandom.longs方法的具體用法?Java ThreadLocalRandom.longs怎麽用?Java ThreadLocalRandom.longs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.concurrent.ThreadLocalRandom
的用法示例。
在下文中一共展示了ThreadLocalRandom.longs方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testBadStreamSize
import java.util.concurrent.ThreadLocalRandom; //導入方法依賴的package包/類
/**
* 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: testBadStreamBounds
import java.util.concurrent.ThreadLocalRandom; //導入方法依賴的package包/類
/**
* 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);
}