public class SampleThread{
public static void main(String[] args)throws Exception{
NumberThread nt = new NumberThread("bbbbbbbbbbbbbbb");
nt.start();
Thread.yield();
//Thread.sleep(1);
System.out.println(111111);
System.out.println(222222);
System.out.println(333333);
System.out.println(444444);
}
}
class NumberThread extends Thread{
public NumberThread(String name)
{
super(name);
}
public void run(){
for(int i = 1; i <= 10; i++){
System.out.println("\t"+getName() + ":" + i);
}
}
}
线程调用了yield()方法之后,这个线程是进入阻塞状态,那他是什么时候变成可运行状态的呢?
也就是,当一个线程调用了yield()方法后,是否直接参与争抢CPU运行机会?