Monitor类提供了一种互斥锁机制,确保同一时间只有一个线程可以访问临界区。它是C#中
lock语句的基础,通过
Monitor.Enter
Monitor.Exit实现锁的获取和释放。