Multiple choice technology programming languages

What of the following fails to cause a thread stop executing ?

  1. The program exits via a call to System.exit(0);

  2. Another thread is given a higher priority.

  3. A call to the thread's stop method.

  4. A call to the halt method of the Thread class.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Options A, B, and C all cause threads to stop: System.exit() terminates the JVM, higher priority threads can preempt lower priority ones, and the stop() method (deprecated) stops threads. However, option D refers to 'halt method' - the Thread class has no such method. The correct method is interrupt() for cooperative cancellation, or stop() (deprecated), but halt() does not exist.