What is the priority of the thread in the following Java Program? [code] class multithreaded_programing { public static

What is the priority of the thread in the following Java Program?
Code:
    class multithreaded_programing 
    {
        public static void main(String args[])
        {
            Thread t = Thread.currentThread();
            System.out.println(t);        
        }
    }
A. 4
B. 5
C. 0
D. 1
 
Answer: b
Explanation: The output of program is Thread[main,5,main], in this priority assigned to the thread is 5. It’s the default value. Since we have not named the thread they are named by the group to they belong i:e main method.
Output:
Code:
$ javac multithreaded_programing.java
$ java multithreaded_programing
Thread[main,5,main]
 

Tìm kiếm

Back
Top