题目描述
解析:
class Foo {
public int a = 0;
public Foo() {
}
public void first(Runnable printFirst) throws InterruptedException {
// printFirst.run() outputs "first". Do not change or remove this line.
printFirst.run();
a++;
}
public void second(Runnable printSecond) throws InterruptedException {
while(true){
if(a == 1){
printSecond.run();
a++;
break;
}else{
Thread.yield();
}
}
// printSecond.run() outputs "second". Do not change or remove this line.
}
public void third(Runnable printThird) throws InterruptedException {
while(true){
if(a == 2){
printThird.run();
break;
}else{
Thread.yield();
}
}
// printThird.run() outputs "third". Do not change or remove this line.
}
}