class Program
{
static void Main(string[] args)
{
Thread thread1 = new Thread(new ThreadStart(fun_thread1));
Thread thread2 = new Thread(new ThreadStart(fun_thread2));
thread1.Start();
thread2.Start();
}
static void fun_thread1()
{
for (int i = 1; i < 60;i++ )
{
Console.WriteLine( " 1");
Thread.Sleep(30);
}
}
static void fun_thread2()
{
for (int i = 1; i < 60;i++ )
{
Console.WriteLine( " 2");
Thread.Sleep(30);
}
}
}
为什么运行出来的结果是1、2交替的啊??不应该是无序的吗???不知道是不是sleep和时间片的原因,把sleep去掉就是无序了,但是我需要让这两个进程隔一段时间执行一次而且要无序~~~
新人求助啊!!!