C# Monitor,Busy Wait,True Wait & SpinLock

added by sankarsan
8/21/2010 6:39:37 AM

1 Kicks, 182 Views

In my last two posts I had discussed about thread synchronization,critical sections and System.Threading.Monitor class.What we have seen is, a critical section in the code where thread synchronization is required is protected by a lock.When a thread encounters a critical section it tries to acquire the lock,if successful it executes the code or else waits to acquire the lock.Now when we say wait, what exactly happens?.There are two possible ways this can be done.