Java: Why main class does not extend Thread class [closed]

You are confused a bit. All code runs in some thread, yet the class that defines this code needs not extend Thread. If this were not so, all classes had to extend Thread or you couldn’t call any of their methods.

Look at the following analogy:

public class Test {
    public static void main(String[] args) {
         System.err.println("foo");
    }
}

Now ask yourself why Test does not extend System, and yet it uses fields and methods from System. If you know this, then you can also answer your original question.

Browse More Popular Posts

Leave a Comment