For Thread Synchronization, if you are thinking about any big shot logic, Then I want your attention over following piece of code. By using this approach we can very easily achieve resource locking mechanism.
class Account { // this class should behave like a monitor
long val =0;
public void Deposit(long x) {
lock (this) { val += x; } // only 1 thread at a time may execute this statement
}
public void Withdraw(long x) {
lock (this) { val -= x; }
}
OR
Monitor.Enter(val);
try {
Statement
} finally {
Monitor.Exit(val); 