Type of issue
Race Condition
Description
in this part of the code:
Interlocked.Add(ref padding, 100);
Console.WriteLine("Task {0} enters the semaphore.", Task.CurrentId);
// The task just sleeps for 1+ seconds.
Thread.Sleep(1000 + padding);
The return value of Interlocked.Add should have been used in Thread.Sleep(1000 + padding) instead of direct usage of padding.
Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.threading.semaphoreslim?view=net-10.0
Content source URL
https://github.com/dotnet/dotnet-api-docs-temp/blob/live/xml/System.Threading/SemaphoreSlim.xml
Document Version Independent Id
00dfa695-b15e-171a-bb3f-6406d5251394
Platform Id
3555abfc-a4c2-7751-ffba-f0547432065b
Article author
@dotnet-bot
Type of issue
Race Condition
Description
in this part of the code:
The return value of
Interlocked.Addshould have been used inThread.Sleep(1000 + padding)instead of direct usage ofpadding.Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.threading.semaphoreslim?view=net-10.0
Content source URL
https://github.com/dotnet/dotnet-api-docs-temp/blob/live/xml/System.Threading/SemaphoreSlim.xml
Document Version Independent Id
00dfa695-b15e-171a-bb3f-6406d5251394
Platform Id
3555abfc-a4c2-7751-ffba-f0547432065b
Article author
@dotnet-bot