Locks Mutex Semaphore
Locks Mutex Semaphore
TECHNIQUES
Thread
Thread States
Lock
It ensures only one thread to be executed in given moment of time.
The lock keyword marks a statement block as a critical section by obtaining the mutual-
exclusion lock for a given object, executing a. statement and then releasing the lock
Monitor
Lock keyword is just a short-form of Monitor.
The Monitor class has the following methods for the synchronize access to a region of code by taking and
releasing a lock:
Monitor.Enter
Monitor.TryEnter
Monitor.Exit.
Disadvantages:
Interaction between threads add complexity
Creation / tear down cost.
To be continued..
SemaphoreSlim
ReaderWriter locks
Interlocked class
SpinLocks
Deadlocks