Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 2
Thread vs runnable interface which one is best
3 Respostas
+ 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