class Program { static void Main(string[] args) { var t = new Thread(()=>Process(10)); t.Start(); Console.WriteLine("老師等待提交試卷"); _StudentEvent.WaitOne(); Console.WriteLine("老師正在批閱英語試卷"); Thread.Sleep(TimeSpan.FromSeconds(5)); Console.WriteLine("老師批閱完成,打100分"); _TeacherEvent.Set(); Console.ReadKey(); } static AutoResetEvent _StudentEvent = new AutoResetEvent(false); static AutoResetEvent _TeacherEvent = new AutoResetEvent(false); static void Process(int seconds) { Console.WriteLine("學生開始考英語"); Thread.Sleep(TimeSpan.FromSeconds(seconds)); Console.WriteLine("學生交卷"); _StudentEvent.Set(); Console.WriteLine("等待老師批閱"); _TeacherEvent.WaitOne(); Console.WriteLine("學生領到試卷"); } }