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
優先級越高,得到資源的概率就越大,但并不表示它就一定獲得資源,優先級小的線程也可能比優先級高的線程先獲取資源
*/
}
}
/**
* 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
優先級越高,得到資源的概率就越大,但并不表示它就一定獲得資源,優先級小的線程也可能比優先級高的線程先獲取資源
*/
}
}
轉載于:https://www.cnblogs.com/anxbb/p/8425439.html
總結
- 上一篇: 网络加载空页面
- 下一篇: python学习随笔day3