The invocation of Monitor.Pulse(...)
notifies a Monitor.Wait(...)
that is enclosed by a while
loop that depends on a method parameter. Due to the parameter dependence of the while
loop, there can be multiple threads with semantically different conditions. Because of the reason that it is not possible to signal a specific thread, it may lead to the signalization of the wrong one.
Replace the invocation of Monitor.Pulse(...)
with Monitor.PulseAll(...)
to always signal all waiting threads.