A random number generator isolated to the current thread. Like the global {@link java.util.Random} generator used by the {@link java.lang.Math} class, a {@code ThreadLocalRandom} is initializedwith an internally generated seed that may not otherwise be modified. When applicable, use of {@code ThreadLocalRandom} ratherthan shared {@code Random} objects in concurrent programs willtypically encounter much less overhead and contention. Use of {@code ThreadLocalRandom} is particularly appropriate when multipletasks (for example, each a {@link ForkJoinTask}) use random numbers in parallel in thread pools.
Usages of this class should typically be of the form: {@code ThreadLocalRandom.current().nextX(...)} (where{@code X} is {@code Int}, {@code Long}, etc). When all usages are of this form, it is never possible to accidently share a {@code ThreadLocalRandom} across multiple threads.
This class also provides additional commonly used bounded random generation methods.
@since 1.7
@author Doug Lea