public final class ThreadRandom extends ThreadLocal<Random>
Modifier and Type | Method and Description |
---|---|
protected Random |
initialValue()
Returns the current thread's "initial value" for this thread-local
variable.
|
static void |
nextBytes(byte[] bytes)
Generates a user-specified number of random bytes.
|
static int |
nextInt()
Returns the next pseudorandom, uniformly distributed integer value.
|
get, remove, set, withInitial
protected Random initialValue()
ThreadLocal.get()
method, unless the thread previously
invoked the ThreadLocal.set(T)
method, in which case the initialValue
method will not be invoked for the thread. Normally, this method is
invoked at most once per thread, but it may be invoked again in case of
subsequent invocations of ThreadLocal.remove()
followed by ThreadLocal.get()
.initialValue
in class ThreadLocal<Random>
InternalError
- if an error occurs creating the initial value-public static void nextBytes(byte[] bytes)
bytes
- the array to be filled in with random bytes.NullPointerException
- if bytes
is null
.public static int nextInt()
Copyright © OBCOM INGENIERIA S.A. (Chile). All Rights Reserved.