ManualResetEvent Vs AutoResetEvent
ManualResetEvent can be used for notifying one or more threads that an event has occured. And unless and untill reset is called manually, reset of the signal is not done. Whereas AutoResetEvent can be used for notifying only one thread that the event has occured and again it resets its state. Example: class Program { public static int x = 0; public static int y = 0; public static int z = 0; public static bool thread1Turn = true; public static bool thread2Turn = true; public static bool thread3Turn = true; public static ManualResetEvent manualResetEvent = new ManualResetEvent(false); public static AutoResetEvent autoResetEvent = new AutoResetEvent(false); static void Main(string[] args) { Thread th1 = new Thread(fn1); th1.Start(); Thread th3 = new Thread(fn3); th3.Start(); Thread th2 = new Thread(fn2); th2.Start(); Console.ReadLine(); } static void fn1() { while(thread1Turn) { autoResetEvent.WaitOne(); //Now this thread is waiting for the event to go i...