2 using System
.Threading
;
6 public static ManualResetEvent e
;
8 // Code for first thread
9 public static void ThreadMethod_waiter_1()
11 Console
.WriteLine("[Thread A] - Started.....");
12 Console
.WriteLine("[Thread A] - I'm before wait for event .....");
14 Console
.WriteLine("[Thread A] - I'm after wait for event.");
17 // Code for second thread
18 public static void ThreadMethod_waiter_2()
20 Console
.WriteLine("[Thread B] - Started.....");
21 Console
.WriteLine("[Thread B] - I'm before wait for event .....");
23 Console
.WriteLine("[Thread B] - I'm after wait for event.");
26 // Code for 3th thread
27 public static void ThreadMethod_blocker()
29 Console
.WriteLine("[Thread C] - Started.....");
30 Console
.WriteLine("[Thread C] - Sleeping for 5000ms....");
32 Console
.WriteLine("[Thread C] - Setting the event....");
34 Console
.WriteLine("[Thread C] - Finished.....");
38 public static void Main()
40 e
= new ManualResetEvent(false);
43 // Create the waiter thread's group
44 Console
.WriteLine("[ Main ] - Creating first thread..");
45 ThreadStart Thread_1
= new ThreadStart(ThreadMethod_waiter_1
);
46 ThreadStart Thread_2
= new ThreadStart(ThreadMethod_waiter_2
);
48 // Create the blocker thread
49 Console
.WriteLine("[ Main ] - Creating second thread..");
50 ThreadStart Thread_3
= new ThreadStart(ThreadMethod_blocker
);
52 Thread A
= new Thread(Thread_1
);
53 Thread B
= new Thread(Thread_2
);
54 Thread C
= new Thread(Thread_3
);
61 Console
.WriteLine("[ Main ] - Finish...");