java 主线程优先级的值是多少?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1269807/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
what is the value for main thread priority?
提问by Johanna
all threads have its priority,so what is the integer value for main thread?
所有线程都有其优先级,那么主线程的整数值是多少?
回答by OscarRyz
This code shows you the priority of the main thread:
这段代码显示了主线程的优先级:
public class Main {
public static void main( String [] args ) {
System.out.println( Thread.currentThread().getPriority() );
}
}
The output, and the answer to your question, is 5.
输出以及您问题的答案是5。
回答by Hyman Leow
If you still have any doubts, have a look at the JDK's API docs:
如果您仍然有任何疑问,请查看 JDK 的 API 文档:
From http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#NORM_PRIORITY:
从http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#NORM_PRIORITY:
NORM_PRIORITY
public static final int NORM_PRIORITYThe default priority that is assigned to a thread.
NORM_PRIORITY
public static final int NORM_PRIORITY分配给线程的默认优先级。
From http://java.sun.com/j2se/1.5.0/docs/api/constant-values.html#java.lang.Thread.NORM_PRIORITY:
从http://java.sun.com/j2se/1.5.0/docs/api/constant-values.html#java.lang.Thread.NORM_PRIORITY:
static final int NORM_PRIORITY 5
static final int NORM_PRIORITY 5
回答by rajshri
by default thread value is 6 .......
默认线程值为 6 ......

