public class TestYield implements Runnable {
@Override
public void run() {
for (int i = 0; i < 20; i++) {
if ("Thread-0".equals(Thread.currentThread().getName())){
if (i==0){
Thread.yield();
}
} System.out.println(Thread.currentThread().getName() + " : " + i);
}
}
public static void main(String[] args) {
Thread t=new Thread(new TestYield());
Thread t2=new Thread(new TestThread());
t.start();
t2.start();
}
}
//我的没有让步是因为什么