public long nextLong(long n) {
        if (n <= 0)
            throw new IllegalArgumentException("n must be positive");
        // Divide n by two until small enough for nextInt. On each
        // iteration (at most 31 of them but usually much less),
        // randomly choose both whether to include high bit in result
        // (offset) and whether to continue with the lower vs upper
        // half (which makes a difference only if odd).
        long offset = 0;
        while (n >= Integer.MAX_VALUE) {
            int bits = next(2);
            long half = n >>> 1;
            long nextn = ((bits & 2) == 0) ? half : n - half;
            if ((bits & 1) == 0)
                offset += n - nextn;
            n = nextn;
        }
        return offset + nextInt((int) n);
    }
Returns a pseudorandom, uniformly distributed value
between 0 (inclusive) and the specified value (exclusive).

@param n the bound on the random number to be returned.  Must be
       positive.
@return the next value
@throws IllegalArgumentException if n is not positive
lts-core/src/main/java/com/github/ltsopensource/core/commons/concurrent/ThreadLocalRandom.java