一、線程的優先順序 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.歡迎關註微信公眾號:傅里葉變換,個人公眾號,僅用於學習交流,後臺回覆”禮包“,獲取大數據學習資料