Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- using System.Threading.Tasks;
- namespace Chapter1
- {
- public class Program
- {
- static void Main()
- {
- object lockA = new object();
- object lockB = new object();
- var up = Task.Run(() =>
- {
- lock (lockA)
- {
- Thread.Sleep(1000);
- lock (lockB)
- {
- Console.WriteLine("Locked A and B");
- }
- }
- });
- lock (lockB)
- {
- lock (lockA)
- {
- Console.WriteLine("Locked B and A");
- }
- }
- up.Wait();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement