MCQs>IT & Programming>C#>What will be the output of the following code : public static void Main() { int value = 1; Task t1 = Task.Run(() => { if (value == 1) { Thread.Sleep(1000); value = 2; } }); Task t2 = Task.Run(() => { value = 3; }); Task.WaitAll(t1, t2); Console.WriteLine(value); Console.ReadLine(); }
C# MCQs
What will be the output of the following code : public static void Main() { int value = 1; Task t1 = Task.Run(() => { if (value == 1) { Thread.Sleep(1000); value = 2; } }); Task t2 = Task.Run(() => { value = 3; }); Task.WaitAll(t1, t2); Console.WriteLine(value); Console.ReadLine(); }
Answer
Correct Answer: 2
Explanation:
Note: This Question is unanswered, help us to find answer for this one