mythread.start() The above statement is not starting the new thread.It just calls the overridden start() method in MyThread class.
Thats why you got the output : MyThread: start()
thread.start(); This statement starts the newly created thread.This will access start() method declared in Thread class which in turn calls run() method declared in MyRunnable class which results in the output MyRunnable: run()
mythread.start() calls the start() of MyThread alone thread.start() calls the start() of Thread class which calls run() of MyRunnable.
Originally posted by dolly shah: I got the output. But I have another question. Why MyRunnable class is able to implement start() method. It is not a Runnable interface method. can you explain?
For the same reason the MyRunnable class is able to implement a method named join(), alive(), hello(), goodbye(), mymethod1(), mymethod2(), etc. Just because you implement an interface, doesn't mean that you are not allowed to have methods that is not part of that interface.