Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the value for main thread priority?

all threads have its priority,so what is the integer value for main thread?

like image 249
Johanna Avatar asked Aug 13 '09 03:08

Johanna


2 Answers

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.

like image 138
OscarRyz Avatar answered Oct 08 '22 15:10

OscarRyz


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

like image 21
Jack Leow Avatar answered Oct 08 '22 17:10

Jack Leow