Answer the question
In order to leave comments, you need to log in
What is the difference between the run method from Thread and the same method from Runnable?
Help me understand the difference between the run method from the Thread class and the same method from the Runnable interface, do they even exist?
Answer the question
In order to leave comments, you need to log in
I'll tell you something terrible now: Thread is Runnable . So no difference.
Runnable
- task interface with method run()
. Thread
- task executor in a new thread.
It Thread
also implements the interface Runnable
and launches its own task defined in its method run()
in a new thread; by default, its task is to launch another task passed to it, for example, through the constructor new Thread(Runnable)
.
The method run()
on the Thread object is never called on its own, since the essence of the Thread object is to create a new thread, and then the jvm itself will start executing the task by calling the method run()
in the new thread.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question