i have this code:
Thread[] threadsArray = new Thread[4];
for (int i = 0; i < 4; i++)
{
threadsArray[i] = new Thread(() => c1.k(i));
}
for (int i = 0; i < 4; i++)
{
threadsArray[i].Start();
}
for (int i = 0; i < 4; i++)
{
threadsArray[i].Join();
}
the function k is this:
void k(int i)
{
while(true)
Console.WriteLine(i);
}
for some reason just the last thread is running and printing 4444444.... why aren't all the threads running?