Gaurav Ag wrote:Let's take an example of Runnable interface. I do know that all the Thread methods (like start() method) goes into Thread class. So if in my class, I am implementing the run() function, how it is going to call the method of Thread class.
Your Runnable doesn't call the methods of the Thread class. Or at least, it doesn't have to. It can if it needs Thread's functionality, like interrupting itself or another thread.
As per my understanding, a very basic definition of Runnable interface should be something like -
So how overriding the run() method will actually call the methods in Thread class?
It doesn't, unless you choose to because that's what you need to do to make your runnable work.
Rather, the thread calls the Runnable's run() method. That's the whole point. Thread is saying, "You give me a Runnable, and I'll call its run() method in a new thread of execution."