diff --git a/src/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs b/src/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs index cdcd55caac0..beae3e6f23f 100644 --- a/src/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs +++ b/src/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs @@ -778,14 +778,12 @@ public int Release(int releaseCount) // Signal to any synchronous waiters int waitCount = m_waitCount; - if (currentCount == 1 || waitCount == 1) + + int waitersToNotify = Math.Min(releaseCount, waitCount); + for (int i = 0; i < waitersToNotify; i++) { m_condition.SignalOne(); } - else if (waitCount > 1) - { - m_condition.SignalAll(); - } // Now signal to any asynchronous waiters, if there are any. While we've already // signaled the synchronous waiters, we still hold the lock, and thus