Topics Index


If you need explanation Read this topic

If you need Answer Take test on this topic

What will be the output of the following program?
public class ThreadQuestion {
    public static void main(String[] args) {
        Thread t = new Thread();
        System.out.println("Minimum = " + Thread.MIN_PRIORITY);
        System.out.println("Maximum = " + Thread.MAX_PRIORITY);

A. Minimum = 0
Maximum = 10
class java.lang.ThreadQuestion
B. Minimum = 1
Maximum = 10
class java.lang.Thread
C. Compilation Error
D. Runtime Error
Topic: Thread Concept In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans B
Here thread concept is used. It is multintasking concept and min priority is 1 and Max priority is 10 and get. Will print class name.
So the I hope B is correct

Posted by Fuzail Ahmed    2014-12-26 12:48:16

ns is we have the Threads Priority Concept...By default every thread has the default Priority as 5...and we set the Priority for the threads using the setPriority() and we can get the Priority of thread using getPriority()..Priorities ranges from 1-10..
in Thread class we have some static final variables
Priorities are useful when multiple threads are waiting for the same resource..when we have only one thread than Priorities dont have any significance..Based on the Priorities threads will get the usage of resource.. and we are calling the getClass() on thread object so it will return the class name as Thread..Thread class Present in the java.lang package

Posted by Uday Kumar    2014-12-26 13:03:41

b.... here we are using the concept of thread......Java threads are objects like any other Java objects. Threads are instances of class java.lang.Thread, or instances of subclasses of this class. In addition to being objects, java threads can also execute code.......Creating a thread in Java is done like this:  Thread thread = new Thread(); .....features of java thread-->>All Java threads have a priority and the thread with he highest priority is scheduled to run by the JVM.....2)In case two threads have the same priority a FIFO ordering is followed..Thread PrioritiesJVM selects to run a Runnable thread with the highest priority.All Java threads have a priority in the range 1-10......  .Top priority is 10, lowest priority is 1.Norml priority ie. priority by default is 5.Thread.MIN_PRIORITY - minimum thread priority.....Thread.MAX_PRIORITY - maximum thread priority. ThreadNORM_PRIORITY - maximum thread priority.  .....Whenever a new Java thread is created it has the same priority as the thread which created it..... here in the peint statement firstly min priority so it will print 1 then it is asking for max priority so it will print 10 the function getclass() in java is used to obtain the respective class... sp it will print the java. lang. thread

Posted by Asma Mujtaba Khan    2014-12-26 13:04:58


In above Example Concept of "Thread" is used.Thread helps in acheiving "MULTITHREADING" concept.Thread is nothing but small process which is executed concurrently with another thus increasing CPU throughput.

--In java,"Thread" class is available in "java.lang" package.Object of "Thread" class is created.

--Thread can have priority from 1 to 10.Thread with more priority will get more time of CPU Resource.

There are three Static final variable in thread class:


--As they are static variables so they are called with class name(Thread) as follows :

--getclass() function of thread class is used to return the name of class with the package in which it is residing  i.e. java.lang.Thread

Posted by Mânïshå Mùlchåndânï    2014-12-26 18:04:37

This dose is now closed and the winners are Fuzail Ahmed,  for 'First Correct Comment', Uday Kumar,  for 'Best Comment' and Uday Kumar for the 'Popular Comment'. The 'lucky liker' is Maheshwari Natarajan. Please login into Merit Campus using facebook, to claim your recharge. Go to to raise the recharge.

Posted by Merit Campus    2014-12-29 05:11:36

© meritcampus 2019

All Rights Reserved.

Open In App