Java线程- main方法的优先级
package com.mldn;
public class PriorityIntValue
{
public static void main(String[] args)
{
System.out.println(“main方法的优先级是:” + Thread.currentThread().getPriority()); // 获取主方法的优先级
System.out.println(“Thread.MAX_PRIORITY = ” + Thread.MAX_PRIORITY); // 获取优先级的int值
System.out.println(“Thread.NORM_PRIORITY = ” + Thread.NORM_PRIORITY);
System.out.println(“Thread.MIN_PRIORITY = ” + Thread.MIN_PRIORITY);
}
}
/*
administrator@xu-desktop:~$ javac -d . ./work/PriorityIntValue.java
administrator@xu-desktop:~$ java com.mldn.PriorityIntValue
main方法的优先级是:5
Thread.MAX_PRIORITY = 10
Thread.NORM_PRIORITY = 5
Thread.MIN_PRIORITY = 1
可以看出mian方法是采用普通优先级运行的!
*/
声明: 除非转自他站(如有侵权,请联系处理)外,本文采用 BY-NC-SA 协议进行授权 | 智乐兔
转载请注明:转自《Java线程- main方法的优先级》
本文地址:https://www.zhiletu.com/archives-71.html
关注公众号:
微信赞赏支付宝赞赏