From b30c877f74ff52f3ded4bb49b1c0fe6fe3fae20f Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Fri, 19 Mar 2021 11:07:16 -0400 Subject: [PATCH] document thread safety for RNGs --- stdlib/Random/docs/src/index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stdlib/Random/docs/src/index.md b/stdlib/Random/docs/src/index.md index 4e8ace596543a..ca86de44ecce4 100644 --- a/stdlib/Random/docs/src/index.md +++ b/stdlib/Random/docs/src/index.md @@ -13,7 +13,9 @@ type, which is a wrapper over the OS provided entropy. Most functions related to random generation accept an optional `AbstractRNG` object as first argument, which defaults to the global one if not provided. Moreover, some of them accept optionally dimension specifications `dims...` (which can be given as a tuple) to generate arrays of random -values. +values. In a multi-threaded program, you should generally use different RNG objects from different threads +in order to be thread-safe. However, the default global RNG is thread-safe as of Julia 1.3 (because +it internally corresponds to a per-thread RNG). A `MersenneTwister` or `RandomDevice` RNG can generate uniformly random numbers of the following types: [`Float16`](@ref), [`Float32`](@ref), [`Float64`](@ref), [`BigFloat`](@ref), [`Bool`](@ref),