Multithreading
- What is the output of this program?
public class multithreading_Example
{
public static void main(String args[])
{
Thread thread = Thread.currentThread();
thread.setName("Thread one");
System.out.println(thread);
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Thread[Thread one,5,main]
- What is the priority of the thread in output of this program?
public class multithreaded_PriorityExample
{
public static void main(String args[])
{
Thread thread = Thread.currentThread();
thread.setName("Thread One");
System.out.println(thread.getPriority());
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
The getPriority() function is used to obtain the priority of the thread, in this code the priority given to thread is ‘5’.
- What is the name of the thread in output of this program?
public class multithreading_NameExample
{
public static void main(String args[])
{
Thread thread = Thread.currentThread();
thread.setName("Thread One");
System.out.println(thread.getName());
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
The getName() function is used to obtain the name of the thread, in this code the name given to thread is ‘Thread One’.
- What is the output of the thread in output of this program?
public class Output
{
public static void main(String args[])
{
Thread thread = Thread.currentThread();
System.out.println(thread.isAlive());
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Thread t is seeded to currently program, hence when you run the program the thread becomes active & code ‘thread.isAlive’ returns true.
- What is multithreaded programming?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Multithreaded programming a process in which two or more parts of the same process run simultaneously.