Using multi threading inside For loop in C#

anirudhp
 
on Feb 15, 2021 04:49 AM
1262 Views

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();
}

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download