![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/0c5a785e95b3219ae7407eb6e7cd1b8c.png)
程序
package thread;
public class PriorityTest implements Runnable{
@Override
public void run() {
System.out.println(Thread.currentThread().getName());
}
public static void main(String[] args) {
PriorityTest priorityTest = new PriorityTest();
Thread thread1 = new Thread(priorityTest,"线程——>1");
Thread thread2 = new Thread(priorityTest,"线程——>2");
Thread thread3 = new Thread(priorityTest,"线程——>3");
Thread thread4 = new Thread(priorityTest,"线程——>4");
Thread thread5 = new Thread(priorityTest,"线程——>5");
Thread thread6 = new Thread(priorityTest,"线程——>6");
Thread thread7 = new Thread(priorityTest,"线程——>7");
Thread thread8 = new Thread(priorityTest,"线程——>8");
Thread thread9 = new Thread(priorityTest,"线程——>9");
Thread thread10 = new Thread(priorityTest,"线程——>10");
thread1.setPriority(Thread.MIN_PRIORITY);
thread1.start();
thread2.setPriority(2);
thread2.start();
thread3.setPriority(3);
thread3.start();
thread4.setPriority(4);
thread4.start();
thread5.setPriority(Thread.NORM_PRIORITY);
thread5.start();
thread6.setPriority(6);
thread6.start();
thread7.setPriority(7);
thread7.start();
thread8.setPriority(8);
thread8.start();
thread9.setPriority(9);
thread9.start();
thread10.setPriority(Thread.MAX_PRIORITY);
thread10.start();
}
}
https://www.bilibili.com/video/BV1V4411p7EF?p=16