线程的优先级

package 多线程练习;

public class Thread优先级 {
public static void main(String[] args) {
Runnable runnable = () -> {
System.out.println("线程名:" + Thread.currentThread().getName() + " <-> 优先级:" + Thread.currentThread().getPriority());
};

// 装载线程
Thread t1 = new Thread(runnable, "t1");
Thread t2 = new Thread(runnable, "t2");
Thread t3 = new Thread(runnable, "t3");
Thread t4 = new Thread(runnable, "t4");
Thread t5 = new Thread(runnable, "t5");

// 设置优先级的大小 具体实际优先级看CPU的调度 设置还是能代表一定的优先权重
t1.setPriority(Thread.MIN_PRIORITY);
t1.start();

t2.setPriority(2);
t2.start();

t3.setPriority(3);
t3.start();


t4.start();

t5.setPriority(Thread.MAX_PRIORITY);
t5.start();


}
}
上一篇:T5 —— 从尾到头反过来返回每个节点的值


下一篇:CNA, FCoE, TOE, RDMA, iWARP, iSCSI等概念及 Chelsio T5 产品介绍