java学习(95):线程的优先级
生活随笔
收集整理的這篇文章主要介紹了
java学习(95):线程的优先级
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
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);//數(shù)字越大,優(yōu)先級(jí)越高,默認(rèn)為5xc11.start();xc12.start();}
}
class Xc41 extends Thread {public void run(){for (int i=0;i<20;i++){System.out.println("第一個(gè)線程在被執(zhí)行"+i);}}
}
class Xc42 extends Thread {public void run(){for (int i=0;i<20;i++){System.out.println("i線程"+i);}}
}
運(yùn)行結(jié)果
總結(jié)
以上是生活随笔為你收集整理的java学习(95):线程的优先级的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 带wiringPi库的交叉编译
- 下一篇: VB编程:GetSetting控制软件试