线程优先级高,只是权重高,获得CPU调度的概率高,并不是一定排前面
package com.chenxb.myThread;
public class TestPriority {
public static void main(String[] args) {
Thread thread1= new Thread(()-> System.out.println("111"));
thread1.setPriority(1);
thread1.start();
Thread thread2= new Thread(()-> System.out.println("222"));
thread2.setPriority(2);
thread2.start();
Thread thread3= new Thread(()-> System.out.println("333"));
thread3.setPriority(3);
thread3.start();
Thread thread4= new Thread(()-> System.out.println("444"));
thread4.setPriority(4);
thread4.start();
Thread thread5= new Thread(()-> System.out.println("555"));
thread5.setPriority(Thread.MAX_PRIORITY);
thread5.start();
}
}