public class test30 { public static void main ( String [] args ){ Thread xc11 = new Thread ( new Xc41 ()); Thread xc12 = new Thread ( new Xc42 ()); xc11 . setPriority ( Thread . NORM_PRIORITY + 3 ); //数字越大,优先级越高,默认为
public class test30 {
public static void main(String[] args){
Thread xc11=new Thread(new Xc41());
Thread xc12=new Thread(new Xc42());
xc11.setPriority(Thread.NORM_PRIORITY+3);//数字越大,优先级越高,默认为5
xc11.start();
xc12.start();
}
}
class Xc41 extends Thread {
public void run(){
for (int i=0;i<20;i++){
System.out.println("第一个线程在被执行"+i);
}
}
}
class Xc42 extends Thread {
public void run(){
for (int i=0;i<20;i++){
System.out.println("i线程"+i);
}
}
}
运行结果