Java连载105-线程的优先级
程序员文章站
2022-12-08 22:48:06
一、线程的优先级 1.线程优先级的获取的CPU时间片会相对多一点 (1)优先级为1-10 (2)最低为1 (3)最高为10 (4)默认为5 package com.bjpowernode.java_learning; public class D105_1_PriorotyOfMultithre ......
一、线程的优先级
1.线程优先级的获取的cpu时间片会相对多一点
(1)优先级为1-10
(2)最低为1
(3)最高为10
(4)默认为5
package com.bjpowernode.java_learning; public class d105_1_priorotyofmultithread { public static void main(string[] arsg) { system.out.println(thread.max_priority); system.out.println(thread.min_priority); system.out.println(thread.norm_priority); system.out.println("================="); thread t1 = new processor105(); t1.setname("t1"); thread t2 = new processor105(); t2.setname("t2"); system.out.println(t1.getpriority()); system.out.println(t2.getpriority()); //设置优先级 t1.setpriority(5); t2.setpriority(4); t1.start(); t2.start(); } } class processor105 extends thread{ public void run() { for(int i=0;i<5;i++) { system.out.println(thread.currentthread().getname()+"--->"+i); } } }
三、源码:
d105_1_priorotyofmultithread.java
https://github.com/ruigege66/java/blob/master/d105_1_priorotyofmultithread.java
2.csdn:https://blog.csdn.net/weixin_44630050
3.博客园:https://www.cnblogs.com/ruigege0000/
4.欢迎关注微信公众号:傅里叶变换,个人公众号,仅用于学习交流,后台回复”礼包“,获取大数据学习资料