Multiple choice technology programming languages

Which the preferred way to write multithread programe ?

  1. Extend Thread class

  2. Implement Runnable interface

  3. Both

  4. None

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

Implementing the Runnable interface is preferred over extending the Thread class in Java because Java does not support multiple inheritance. By implementing an interface, the class remains free to inherit from another class. This approach also promotes better separation of concerns between the task execution logic and the thread mechanism.