radha gogia
I just wanted to ask that is the runnable interface is implemented just so that the class can realise the concept of multiple inheritance ,because if our class extends thread class,then our class won't be able to extend any other class,so can anyone plz tell ,is there any advantage other than this..
Strictly speaking, multiple inheritence is not supported in Java.
AFAIK, in many books the concept of threading says that multiple inheritence is supported, but that's not the case. (I would like to clear this from CEans here, if I'm wrong 😀 )
To inherit properties of any class, we extend it. Implementing an interface is a different concept all together.
While Thread class is extended, all it's data members and member functions (methods) would be inherited like setName() method etc. which can create an extra overhead if they are not needed. Hence, Runnable Interface would be preferred.
Though if you want to use the methods, they why not use it by extending Thread class instead. Right?
PS: Tagging #-Link-Snipped-# to shed some light on the topic.