class Program
{
static void Main()
{
Request req = new Request();
//这个人去干三件大事
Thread GetCarThread = new Thread(new ThreadStart(req.InterfaceA));
GetCarThread.Start();
Thread GetHouseThead = new Thread(new ThreadStart(req.InterfaceB));
GetHouseThead.Start();
//等待三件事都干成的喜讯通知信息
AutoResetEvent.WaitAll(req.autoEvents);
//这个人就开心了。
req.InterfaceC();
System.Console.ReadKey();
}
}
public class Request
{
//建立事件数组
public AutoResetEvent[] autoEvents = null;
public Request()
{
autoEvents = new AutoResetEvent[]
{
new AutoResetEvent(false),
new AutoResetEvent(false)
};
}
public void InterfaceA()
{
System.Console.WriteLine("请求A接口");
Thread.Sleep(1000*2);
autoEvents[0].Set();
System.Console.WriteLine("A接口完成");
}
public void InterfaceB()
{
System.Console.WriteLine("请求B接口");
Thread.Sleep(1000 * 1);
autoEvents[1].Set();
System.Console.WriteLine("B接口完成");
}
public void InterfaceC()
{
System.Console.WriteLine("两个接口都已经请求完,正在处理C");
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有