Question: How do you implement thread synchronization (Object.Wait, Notify,and CriticalSection) in C#?
Answer: You want the lock statement, which is the same as Monitor Enter/Exit: lock(obj) { // code } translates to: try { CriticalSection.Enter(obj); // code } finally { CriticalSection.Exit(obj); }
Question:
How do you implement thread synchronization (Object.Wait, Notify,and CriticalSection) in C#? Answer:
You want the lock statement, which is the same as Monitor Enter/Exit: lock(obj) { // code } translates to: try { CriticalSection.Enter(obj); // code } finally { CriticalSection.Exit(obj); } Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
There should not be any Spelling Mistakes.
There should not be any Gramatical Errors.
Answers must not contain any bad words.
Answers should not be the repeat of same answer, already approved.