五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

多線程優(yōu)先級的代碼

2020-04-12 10:23 作者:小垃圾kiki  | 我要投稿
package cn.jd.state;
/*
?* 線程的優(yōu)先級,優(yōu)先級的取值范圍是數(shù)字1-10
?* 在API里面提供了3個常量供我們操作
?* 1.NORM_PRIORITY? 所有線程默認(rèn)是5
?* 2.MIN_PRIORITY???? 1
?* 3.MAX_PRIORITY??? 10
?* 優(yōu)先級代表的是概率事件,不代表絕對的先后順序
?*/
public class PriorityTest {
?? ?public static void main(String[] args) {
//?? ??? ?System.out.println(Thread.currentThread().getPriority());
?? ??? ?Test t=new Test();
?? ??? ?Thread t1=new Thread(t,"1");
?? ??? ?Thread t2=new Thread(t,"2");
?? ??? ?Thread t3=new Thread(t,"3");
?? ??? ?Thread t4=new Thread(t,"4");
?? ??? ?Thread t5=new Thread(t,"5");
?? ??? ?Thread t6=new Thread(t,"6");
?? ??? ?//設(shè)置優(yōu)先級一定要在啟動之前
?? ??? ?t1.setPriority(Thread.MAX_PRIORITY);
?? ??? ?t2.setPriority(Thread.MAX_PRIORITY);
?? ??? ?t3.setPriority(Thread.MIN_PRIORITY);
?? ??? ?t4.setPriority(Thread.MIN_PRIORITY);
?? ??? ?t5.setPriority(Thread.MIN_PRIORITY);
?? ??? ?t6.setPriority(Thread.MIN_PRIORITY);
?? ??? ?t1.start();
?? ??? ?t2.start();
?? ??? ?t3.start();
?? ??? ?t4.start();
?? ??? ?t5.start();
?? ??? ?t6.start();
?? ??? ?
?? ??? ?
?? ?}

}
class Test implements Runnable{

?? ?@Override
?? ?public void run() {
?? ??? ?System.out.println(Thread.currentThread().getName()+"-->"+Thread.currentThread().getPriority());
//?? ??? ?Thread.yield();//禮讓一下還會發(fā)送改變
?? ??? ?
?? ?}
?? ?
}

多線程優(yōu)先級的代碼的評論 (共 條)

分享到微博請遵守國家法律
铁岭县| 特克斯县| 来安县| 通海县| 五家渠市| 长乐市| 阜城县| 兖州市| 阳信县| 平阴县| 广河县| 望奎县| 通许县| 高州市| 平和县| 精河县| 资阳市| 阳西县| 紫阳县| 内黄县| 漳平市| 偃师市| 桑植县| 彰化市| 溧阳市| 钟祥市| 平武县| 基隆市| 南汇区| 额尔古纳市| 安仁县| 高雄县| 贵定县| 青州市| 东山县| 子长县| 宿州市| 西吉县| 盐池县| 德庆县| 三河市|