Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading.Tasks;
- // what will be the output
- public class MyClass
- {
- private static int _count;
- public static void Work()
- {
- for (var i = 0; i < 10; i++)
- {
- _count++;
- }
- }
- public static async Task Main()
- {
- var t1 = Task.Run(Work);
- var t2 = Task.Run(Work);
- await Task.WhenAll(t1, t2);
- Console.WriteLine(_count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment