Skip to content

Commit 981d573

Browse files
stevengjKristofferC
authored andcommittedMar 23, 2021
document thread safety for RNGs (#40109)
(cherry picked from commit 7d117dc)
1 parent 9c452e7 commit 981d573

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

‎stdlib/Random/docs/src/index.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ type, which is a wrapper over the OS provided entropy.
1313
Most functions related to random generation accept an optional `AbstractRNG` object as first argument,
1414
which defaults to the global one if not provided. Moreover, some of them accept optionally
1515
dimension specifications `dims...` (which can be given as a tuple) to generate arrays of random
16-
values.
16+
values. In a multi-threaded program, you should generally use different RNG objects from different threads
17+
in order to be thread-safe. However, the default global RNG is thread-safe as of Julia 1.3 (because
18+
it internally corresponds to a per-thread RNG).
1719

1820
A `MersenneTwister` or `RandomDevice` RNG can generate uniformly random numbers of the following types:
1921
[`Float16`](@ref), [`Float32`](@ref), [`Float64`](@ref), [`BigFloat`](@ref), [`Bool`](@ref),

0 commit comments

Comments
 (0)
Please sign in to comment.