AutoResetEvent线程阻碍

using System.Threading;
public class Foo {

public Foo() {
    
}
static AutoResetEvent _Second = new AutoResetEvent(false);
static AutoResetEvent _Third = new AutoResetEvent(false);
public void First(Action printFirst) {
    
    // printFirst() outputs "first". Do not change or remove this line.
    printFirst();
    _Second.Set();
}

public void Second(Action printSecond) {
    _Second.WaitOne();
    // printSecond() outputs "second". Do not change or remove this line.
    printSecond();
    _Third.Set();
}

public void Third(Action printThird) {
    _Third.WaitOne();
    // printThird() outputs "third". Do not change or remove this line.
    printThird();
}

}

猜你喜欢

转载自blog.csdn.net/bellainvan/article/details/107388205