1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
public void threadLauncher()
{
Thread t = new Thread(new ParameterizedThreadStart(ExecuteThread));
Thread t1 = new Thread(new ParameterizedThreadStart(ExecuteThread));
Thread t2 = new Thread(new ParameterizedThreadStart(ExecuteThread));
Thread t3 = new Thread(new ParameterizedThreadStart(ExecuteThread));
int count = 0;
while(count!= nUpDownNumber.Value)
{
if (!t.IsAlive && count != nUpDownNumber.Value)
{
t = new Thread(new ParameterizedThreadStart(ExecuteThread));
t.Start(list[count]);
count++;
}
Thread.Sleep(200);
if (!t1.IsAlive && count != nUpDownNumber.Value)
{
t1 = new Thread(new ParameterizedThreadStart(ExecuteThread));
t1.Start(list[count]);
count++;
}
Thread.Sleep(200);
if (!t2.IsAlive && count != 100)
{
t2 = new Thread(new ParameterizedThreadStart(ExecuteThread));
t2.Start(list[count]);
count++;
}
Thread.Sleep(200);
if (!t3.IsAlive && count != 100)
{
t3 = new Thread(new ParameterizedThreadStart(ExecuteThread));
t3.Start(list[count]);
count++;
}
Thread.Sleep(200);
}
Thread.CurrentThread.Abort();
} |
Partager