the following items are some of methods which i collected about the synchronization between the multithreads.
volatile
decorate the variable with the key word volatile, which is only for the reference type and some special primitive type
Interlocked
- Interlocked.Increment(ref para);
- Interlocked.Decrement(ref para)
this mechanism is valid only when the para is int or long type.
Monitor
the function Monitor.Enter() and Monitor.Exit()
Monitor.TryEnter(), this is similar to the Enter(), the only difference is if the resource trying to access is already locked by another thread, the Enter() waits until geting the right or timeout but the TryEnter() just returns false.
Lock
lock is an brief expression of Monitor.Enter()(beginning of lock) and Monitor.Exit() (end of lock)
Monitor.
Wait(), wait will hold the current thread until the locked object call the Pulse();
Monitor.Pulse() ,this method is used to tell the Wait() ;
Monitor.PulseAll(),;
Mutex: WaitOne, ReleaseMutex. they are just like the Monitor.Enter() and Monitor.Exit(), but Mutex is a advanced one which is designed for across the process boundary while the Monitor is not. if there is no need for acorss prpcess bounday, the best pratice is to use the Monitor mechanism which is designed for best performance.
EventWaitHandler
ManualResetEvent ,AutoResetEvent ,the difference between those two is that the first needs to call the Reset() to set the event to the unactivated state. the most important methods are Set(), WaitOne() and Reset();




