Join Threads Question

Hello

I have 10 threads which i start that way:

for (int i = 0; i < 10; i++)

{

Thread newThread = new Thread(new ParameterizedThreadStart(BLABLA));

newThread.Start(LALALALA);

}

now i want to Join these 10 threads. how do i do it

(Sorry for the newbie question..)



Answer this question

Join Threads Question

  • Nefer-Ra

    Hi,

    you have to define an array of thread objects to keep variables to call methods on:

    Thread[] tt = new Thread[10];

    for(int j = 0; j < 10; ++j)
    {
      tt[j] = new Thread(new ParameterizedThreadStart(blabla));
    }

    for(int j = 0; j < 10; ++j)
    {
      tt[j].Join();
    }

    --
    SvenC


  • Join Threads Question