In the above program, we created a LockDemo class that contains two static methods ThreadMethod() and Main(). In the ThreadMethod(), we used mutual exclusive lock using lock keyword and Thread.Sleep() method is used to pause the thread execution. In the Main() method we created threads in the while loop.
Program:
Output:
Explanation:
In the above program, we created a LockDemo class that contains two static methods ThreadMethod() and Main(). In the ThreadMethod(), we used mutual exclusive lock using lock keyword and Thread.Sleep() method is used to pause the thread execution. In the Main() method we created threads in the while loop.
need an explanation for this answer? contact us directly to get an explanation for this answer