public void SendFlower()
{
Console.WriteLine("正在送花的途中");
for (int i = 0; i < 10; i++)
{
Thread.Sleep(200);
Console.Write("..");
}
Console.WriteLine("\r\n花已经送到MM手中了,boss");
public class TestMain
{
private static AutoResetEvent ent = new AutoResetEvent(false);
public static void Main()
{
Boy sender = new Boy(ent);
for (int i = 0; i < 3; i++)
{
Thread th = new Thread(new ThreadStart(sender.SendFlower));
th.Start();
ent.WaitOne(); //等待工作
Console.WriteLine("收到了吧,花是我送嘀:)\r\n\r\n");
}
Console.ReadLine();
}
}
public class Boy
{
AutoResetEvent ent;
public Boy(AutoResetEvent e)
{
ent = e;
}
public void SendFlower()
{
Console.WriteLine("正在送花的途中");
for (int i = 0; i < 10; i++)
{
Thread.Sleep(200);
Console.Write("..");
}
Console.WriteLine("\r\n花已经送到MM手中了,boss");