P
Perecli Manole
I am having some strange thread synchronization problems that require me to
better understand the intricacies of Monitor.Wait/Pulse.
I have 3 threads. Thread 1 does a Monitor.Wait in a SyncLock block
protecting a resource. Thread 2 and 3 also have a SyncLock block protecting
the same resource and after executing some code in their blocks they both do
a Monitor.Pulse to hand of the locked resource back to thread 1.
While thread 1 has the resource locked both thread 2 and 3 are blocked at
the beginning of their SyncLock waiting for the resource to be released. The
question is: When thread 1 does a Monitor.Wait what determines the order of
which thread 2 or 3 is allowed to enter their SyncLock? And if thread 2 gets
the resource and then releases it with a Monitor.Pulse, will thread 3 then
get the resource or will thread 1 get it first?
Thanks
Perry
better understand the intricacies of Monitor.Wait/Pulse.
I have 3 threads. Thread 1 does a Monitor.Wait in a SyncLock block
protecting a resource. Thread 2 and 3 also have a SyncLock block protecting
the same resource and after executing some code in their blocks they both do
a Monitor.Pulse to hand of the locked resource back to thread 1.
While thread 1 has the resource locked both thread 2 and 3 are blocked at
the beginning of their SyncLock waiting for the resource to be released. The
question is: When thread 1 does a Monitor.Wait what determines the order of
which thread 2 or 3 is allowed to enter their SyncLock? And if thread 2 gets
the resource and then releases it with a Monitor.Pulse, will thread 3 then
get the resource or will thread 1 get it first?
Thanks
Perry