dotnet / dotnet/dotnet-api-docs

Race condition in sample code

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

Description

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?

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.