线程十三—— 线程优先级权重的设置
注意 这里创建了五个线程 t1 t2 t3 t4 t5 五个线程 分别为每个线程设置优先级
MAX_PRIORITY 最大优先级 十级 默认为五级 优先级
MIN_PRIORITY 最小优先级 一级
package com.yyf.ThreadSleep;// 设置线程优先级public class TestPriority{ public static void main(String[] args) { System.out.println (Thread.currentThread ().getName ()+"--->"+Thread.currentThread ().getPriority ()); MyPriority myPriority = new MyPriority (); Thread t1 = new Thread (myPriority); Thread t2 = new Thread (myPriority); Thread t3 = new Thread (myPriority); Thread t4 = new Thread (myPriority); Thread t5 = new Thread (myPriority); t1.start (); t2.setPriority (Thread.MAX_PRIORITY); t2.start (); t3.setPriority (6); t3.start (); t4.setPriority (8); t4.start (); t5.setPriority (1); t5.start (); }}class MyPriority implements Runnable{ @Override public void run() { System.out.println (Thread.currentThread ().getName ()+"--->"+Thread.currentThread ().getPriority ()); }}