+ 2
Thread vs runnable interface which one is best
3 Respuestas
+ 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.
+ 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..
+ 4
i use ExectorService cause idk how to use Thread or implement runnable lol