C#多线程JOIN方法初探
试一试:线程的插入
//注意添加命名空间
using System.Threading;
static void Main(string[] args)
{
//线程A
Thread ThreadA = new Thread(delegate()
{
for (int i = 0; i <= 100000000; i++)
{
if (i % 1000000 == 0)
{
Console.Write('A');
}
}
});
//线程B
Thread ThreadB = new Thread(delegate()
{
for (int i = 0; i <= 50000000; i++)
{
if (i % 1000000 == 0)
{
Console.Write('B');
}
}
//在这里插入线程A
ThreadA.Join();
for (int i = 0; i <= 50000000; i++)
{
if (i % 1000000 == 0)
{
Console.Write('b');
}
}
});
//启动线程
ThreadA.Start();
ThreadB.Start();
}