using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace ConsoleApplication1
{
class Program
{
public static void print1()
{
for (int i = 0; i < 9; ++i)
{
Console.WriteLine(2 * i);
Thread.Sleep(100);
}
}
public static void print2()
{
for (int i = 0; i < 9; ++i)
{
Console.WriteLine(2 * i + 1);
Thread.Sleep(100);
}
}
static void Main(string[] args)
{
Thread t1 = new Thread(print1);
Thread t2 = new Thread(print2);
t1.Start();
t2.Start();
while (true) ;
}
}
}
执行程序,依次输出0-16