dotnet / dotnet/dotnet-api-docs

Race condition in sample code

Offen
#9,012 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area-System.Threading Pri3 untriaged
Vorherrschende Sprache
C#
Sterne
949
Forks
1.7k
Ø Merge
3 T. 27 Min.
Gemergte PRs (30 T.)
49

Beschreibung

Here we have the code like this:

https://github.com/dotnet/dotnet-api-docs/blob/546ce8963d1c1164c798ab469b3dfbd0f0803a65/snippets/csharp/System.Threading/SemaphoreSlim/Overview/example.cs#L53-L55

Isn't that a race condition? It could happen that once the semaphore is released, the count can change right away by other threads?

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.