+ 2

Thread vs runnable interface which one is best

14th Apr 2017, 4:51 AM
Nikhil - avatar
3 Answers
+ 10
by extending Thread, each of your threads has a unique object associated with it, whereas implementing Runnable, many thread scan share the same object instance. In the Runnable interface approach, only one instance of a class is being created and it has been shared by different threads.
14th Apr 2017, 4:57 AM
Dev - avatar
+ 5
It is a better programming practice to implement your code using Runnable and not Thread. Because you shouldn't decide right there how your task will be executed. An Executor should be used to execute your Runnable maybe on one thread or multiple threads or using thread pool, etc..
14th Apr 2017, 12:41 PM
Tamás Barta
Tamás Barta - avatar
+ 4
i use ExectorService cause idk how to use Thread or implement runnable lol
14th Apr 2017, 4:59 AM