To write parallel code is not a trivial task. There are details to consider and rules to observe.
Could you say the execution result of the following code? Could you explain why?
using System.Threading.Tasks; using static System.Console; class Program { static void Main() { for (var i = 0; i < 10; i++) { Task.Factory.StartNew(() => WriteLine(i)); } ReadLine(); } }
Share your thoughts in the comments. I will explain what is going on in a future post.