Podcast
Questions and Answers
What is the correct way to execute a thread in Java?
What is the correct way to execute a thread in Java?
- By extending the Thread class
- By calling the run() method directly
- By calling the start() method (correct)
- By creating a new instance of the Thread class
What happens when you call the start() method on a thread that has already been started?
What happens when you call the start() method on a thread that has already been started?
- The thread is terminated
- A new thread is created
- The thread is restarted
- An IllegalThreadStateException is thrown (correct)
What is the default priority of a newly created thread in Java?
What is the default priority of a newly created thread in Java?
- A random priority
- The lowest priority possible
- The highest priority possible
- The same priority as the thread that created it (correct)
What is the primary thread that starts when a Java program is executed?
What is the primary thread that starts when a Java program is executed?
What is the purpose of the run() method in a Java thread?
What is the purpose of the run() method in a Java thread?
What kind of scheduling algorithm is used in Java's runtime system?
What kind of scheduling algorithm is used in Java's runtime system?
What is a consequence of a thread being unable to gain regular access to shared resources?
What is a consequence of a thread being unable to gain regular access to shared resources?
Which method of the Thread class is used to invoke the run() method?
Which method of the Thread class is used to invoke the run() method?
How can a Java program be made to use threading?
How can a Java program be made to use threading?
What is the purpose of the setPriority() method in the Thread class?
What is the purpose of the setPriority() method in the Thread class?
What is the purpose of the join() method in the Thread class?
What is the purpose of the join() method in the Thread class?
What is the name of the process in which each thread is given a period of time to run, and then all the other threads of equal priority get their turn at the CPU?
What is the name of the process in which each thread is given a period of time to run, and then all the other threads of equal priority get their turn at the CPU?
What is the result of instantiating a Thread using the default constructor?
What is the result of instantiating a Thread using the default constructor?
Which Java Thread constructor allows you to specify the thread's name?
Which Java Thread constructor allows you to specify the thread's name?
What happens in the run() method of a Java Thread?
What happens in the run() method of a Java Thread?
In which method do we usually call start() for a Java Thread object?
In which method do we usually call start() for a Java Thread object?
What is printed with the statement 'System.out.println( 'In run!
' );' in the MyThread class?
What is printed with the statement 'System.out.println( 'In run! ' );' in the MyThread class?
What is the purpose of calling the start() method in a Java Thread?
What is the purpose of calling the start() method in a Java Thread?