Java Code Examples for io.netty.util.internal.PlatformDependent#threadLocalRandom()

The following examples show how to use io.netty.util.internal.PlatformDependent#threadLocalRandom() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShuffledDnsServerAddressStream.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
private void shuffle() {
    final InetSocketAddress[] addresses = this.addresses;
    final Random r = PlatformDependent.threadLocalRandom();

    for (int i = addresses.length - 1; i >= 0; i --) {
        InetSocketAddress tmp = addresses[i];
        int j = r.nextInt(i + 1);
        addresses[i] = addresses[j];
        addresses[j] = tmp;
    }
}
 
Example 2
Source File: UnitHelp.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
public static int[] randomIntArray(final int length, final int range) {
    final int[] array = new int[length];
    final Random generator = PlatformDependent.threadLocalRandom();
    for (int i = 0; i < array.length; i++) {
        array[i] = generator.nextInt(range);
    }
    return array;
}
 
Example 3
Source File: ThreadLocalInsecureRandom.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
private static Random random() {
    return PlatformDependent.threadLocalRandom();
}