NEW
Font size
WorksheetsThread Priorities
Total questions: 10
Worksheet time: 5mins
What decides thread priority?
Process
Process scheduler
Thread
Thread scheduler
Which of the following line of code is suitable to start a thread ?
class MyThread implements Runnable
{
public static void main(String args[])
{
/* Missing code? */
}
public void run() {}
}
Thread t = new Thread(X);
Thread t = new Thread(X); t.start();
MyThread run = new MyThread();
Thread t = new Thread(run);
t.start();
Thread t = new Thread(); x.run();
What will be the output of the program?
class multithreaded_programing
{
public static void main(String args[])
{
Thread t = Thread.currentThread();
t.setName("New Thread");
System.out.println(t);
}
}
Thread[5,main].
Thread[New Thread,5].
Thread[main,5,main].
Thread[New Thread,5,main]
What is the name of the thread in output of this program?
class multithreaded_programing
{
public static void main(String args[])
{
Thread t = Thread.currentThread();
System.out.println(t.getPriority());
}
}
0
1
5
10
What is the name of the thread in output of this program?
class multithreaded_programing
{
public static void main(String args[])
{
Thread t = Thread.currentThread();
System.out.println(t.isAlive());
}
}
0
1
TRUE
FALSE
What requires less resources?
Thread
Process
Thread and Process
Neither Thread nor Process
What does not prevent JVM from terminating?
Process
Daemon Thread
User Thread
JVM Thread
Which method is called internally by Thread start() method?
execute()
run()
launch()
main()
Execution of a java thread begins on which method call?
start ()
run ()
execute ()
launch ()
Which method is used to make main thread to wait for all child threads?
join ()
sleep ()
wait ()
stop ()
