单线程的程序是不可以同时运行两个for循环的。
但你的要求可以通过代码优化实现,举个例子:
timer1:for i=1 to 100
a=a+i
next itimer2:
for j=1 to 100
b=b+i
next j你想要实现你的目的就应该这样写:
timer1:
static i,a
i=i+1
if i>100 then timer1.enabled=false
a=a+itimer2:
static j,b
j=j+1
if j>100 then timer2.enabled=false
b=b+j
其实还是两个timer交替执行,但代码简化了,并且确实是等价于同时运行。
因为我们PC机本身就是单线程的,只不过操作系统通过算法让CPU交替运行每个程序实现了一个假的但人发觉不出来的多线程