2.6 线程优先级

package 第二章.线程优先级;

/**
* Created by zzq on 2018/1/18.
*/
public class 线程优先级 {
public static class T1 extends Thread{
@Override
public void run() {
System.out.println("-------");
}
}

public static void main(String[] args) {
T1 t1=new T1();
t1.start();
System.out.println(t1.getPriority());
System.out.println(Thread.MIN_PRIORITY);
System.out.println(Thread.MAX_PRIORITY);
System.out.println(Thread.NORM_PRIORITY);
/*
线程的优先级 默认是 5
Thread.MIN_PRIORITY 1
Thread.MAX_PRIORITY 10
Thread.NORM_PRIORITY 5
优先级越高,得到资源的概率就越大,但并不表示它就一定获得资源,优先级小的线程也可能比优先级高的线程先获取资源
*/

}
}
posted @ 2018-02-07 10:31  anxbb  阅读(81)  评论(0编辑  收藏  举报