dotnet / dotnet/dotnet-api-docs

System.Random class and thread safety - mention Random.Shared

Open
#8,899 2 comments 0 reactions 0 assignees View on GitHub
area-System.Runtime Pri3 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

* Docs link: https://learn.microsoft.com/en-us/dotnet/api/system.random?view=net-7.0#the-systemrandom-class-and-thread-safety
* Starting from .NET 6 there is a built-in solution: https://learn.microsoft.com/en-us/dotnet/api/system.random.shared
* IMHO you could delete everything in the section starting from `The following example uses...` and replace with something like `If you require concurrent usage of the Random class from multiple threads, consider using Random.Shared`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.