标签:
public class MreTest1 { public static ManualResetEvent mre = new ManualResetEvent(false); public static void Add() { while (true) { Thread.Sleep(1000); Console.WriteLine(Thread.CurrentThread.Name + "\t生产者"); MreTest2.mre.Set(); mre.Reset(); mre.WaitOne(); } } } public class MreTest2 { public static ManualResetEvent mre = new ManualResetEvent(false); public static void Del() { mre.WaitOne(); while (true) { Thread.Sleep(2000); Console.WriteLine(Thread.CurrentThread.Name + "\t消费者"); MreTest1.mre.Set(); mre.Reset(); mre.WaitOne(); } } }
标签:
原文地址:http://www.cnblogs.com/tgdjw/p/4605808.html