dotnet / dotnet/dotnet-api-docs

Race condition in sample code

Aperta
#9,012 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
area-System.Threading Pri3 untriaged
Lingua principale
C#
Stelle
949
Fork
1.7k
Merge medio
3g 27m
PR unite (30g)
49

Descrizione

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?

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.