9 |
|
import java.util.Random; |
10 |
|
|
11 |
|
/** |
12 |
< |
* A random number generator with the same properties as class {@link |
13 |
< |
* Random} but isolated to the current Thread. Like the global |
14 |
< |
* generator used by the {@link java.lang.Math} class, a |
15 |
< |
* ThreadLocalRandom is initialized with an internally generated seed |
16 |
< |
* that may not otherwise be modified. When applicable, use of |
17 |
< |
* ThreadLocalRandom rather than shared Random objects in concurrent |
18 |
< |
* programs will typically encounter much less overhead and |
19 |
< |
* contention. ThreadLocalRandoms are particularly appropriate when |
20 |
< |
* multiple tasks (for example, each a {@link ForkJoinTask}), use |
21 |
< |
* random numbers in parallel in thread pools. |
12 |
> |
* A random number generator isolated to the current Thread. Like the |
13 |
> |
* global {@link java.util.Random} generator used by the {@link |
14 |
> |
* java.lang.Math} class, a ThreadLocalRandom is initialized with an |
15 |
> |
* internally generated seed that may not otherwise be modified. When |
16 |
> |
* applicable, use of ThreadLocalRandom rather than shared Random |
17 |
> |
* objects in concurrent programs will typically encounter much less |
18 |
> |
* overhead and contention. ThreadLocalRandoms are particularly |
19 |
> |
* appropriate when multiple tasks (for example, each a {@link |
20 |
> |
* ForkJoinTask}), use random numbers in parallel in thread pools. |
21 |
|
* |
22 |
|
* <p>Usages of this class should typically be of the form: |
23 |
|
* {@code ThreadLocalRandom.current().nextX(...)} (where |