InterviewSolution
| 1. |
What is Mutex and how is it different from other Synchronization mechanisms? |
|
Answer» MuTex refers to Mutual Exclusion and as the name suggests, Mutex works on the mutual exclusion principle to lock out any other thread requesting for a resource whose access is already given to some thread. Mutex acts as a flag mechanism that prevents any second thread from accessing a resource, except for the thread which is currently working on it. Unlike other synchronization mechanisms in C#, such as Auto Reset Event which can give the exclusive access of a resource to any thread that calls the set() method, Mutex remembers the thread that gets the resource access, and only that same thread can reset it, thereby giving the true mutual exclusion synchronization. If the thread differs, a mutex exception is thrown. |
|