for (int i = 0; i < 2; i++)
{
Thread thread = new Thread(() =>
{
Console.WriteLine("main index: " + i);
});
thread.Start();
}
for (int i = 0; i < 2; i++)
{
var i2 = i;
Thread thread = new Thread(() =>
{
Console.WriteLine("main index: " + i2);
});
thread.Start();
}