Using multi threading inside For loop in C#

Last Reply 21 days ago By dharmendr

Posted 21 days ago

How to use multi threading under for loop

for( j = 0; j < 100; j++)
{ 
    Thread t1 = new Thread((ThreadStart)ProcessQueue);
    Thread t2 = new Thread((ThreadStart)ProcessQueue);
    t1.Start();
    j++;
    t2.Start();
    j++;
    // main thread processes the queue, too!
    ProcessQueue();
    j++;
    // wait for threads to complete
    //   t1.Join();
    // t2.Join();
}

 

You are viewing reply posted by: dharmendr 21 days ago.