Creating Thread by implementing Runnable interface | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Creating Thread by implementing Runnable interface

I have read that creating threads by implementing the runnable interface is a preferred approach since it allows us to extend classes as well. My question is, won't we have to define every method in the interface first before we get going with our class? If so, won't it be an unnecessary hassle?

17th Aug 2018, 1:03 PM
JayeshSavage
JayeshSavage - avatar
1 Answer
+ 2
yes but there is only one method in the runnable interface, "run()" so it wont be a hassle the important thing is that your class becomes a runnable object and can be used by other classes that call the runnable objects, mainly thread
17th Aug 2018, 1:21 PM
Robert Atkins
Robert Atkins - avatar