1114. 按序打印
作者:
上杉丶零 | 来源:发表于
2020-03-19 13:45 被阅读0次class Foo {
private CountDownLatch second;
private CountDownLatch third;
public Foo() {
second = new CountDownLatch(1);
third = new CountDownLatch(1);
}
public void first(Runnable printFirst) throws InterruptedException {
// printFirst.run() outputs "first". Do not change or remove this line.
printFirst.run();
second.countDown();
}
public void second(Runnable printSecond) throws InterruptedException {
second.await();
// printSecond.run() outputs "second". Do not change or remove this line.
printSecond.run();
third.countDown();
}
public void third(Runnable printThird) throws InterruptedException {
third.await();
// printThird.run() outputs "third". Do not change or remove this line.
printThird.run();
}
}

image.png
本文标题:1114. 按序打印
本文链接:https://www.haomeiwen.com/subject/edxlyhtx.html
网友评论