all threads have its priority,so what is the integer value for main thread?
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.
If you still have any doubts, have a look at the JDK's API docs:
From http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#NORM_PRIORITY:
NORM_PRIORITY
public static final int NORM_PRIORITY
The default priority that is assigned to a thread.
From http://java.sun.com/j2se/1.5.0/docs/api/constant-values.html#java.lang.Thread.NORM_PRIORITY:
static final int NORM_PRIORITY 5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With