多线程速度变慢
比如一个无限循环
Dim 次数 As Integer = 0
Dim Start_T = GetTickCount
Do While True
次数 += 1
Threading.Thread.Sleep(100)
‘’dm.KeyPress(122)
‘’dm.KeyPress(112)
‘’中间所做的事
If 次数 = 50 Then
Dim Stop_T = GetTickCount
Console.WriteLine("运行50次所用时间(毫秒):{0}", Stop_T - Start_T)
次数 = 0
Start_T = GetTickCount
End If
Loop
放到一个class类中用多线程调用,如果是第一次调用循环50次用时10秒,第二次相近,当调用5次以上时,明显变慢,大约用时22秒左右,用线程池也一样,如何调用多次时效率不下降太多呢?什么方法调用都行,我需要同时运行多个上面的的循环。