gurpeet singh wrote:if i have something like this
here "Runnable" is target runnable object and MyThread class extends from Thread. when t.start() is called whether it will invoke run method of Thread class or the runnable passed in the constructor of MyThread and why ?
Hi gurpeet, Do you mean this kind of scenery accordingly following program?
If you wonna mean this, then when t.start() is called at line 24, then it will invoke run method of MyThread class. If you want to this start method will call MyRunnable's Run method, Then you have to call it yourself in run method of MyThread class according line 15. Only Then MyRunnable's Run will be called. If you pass a runnable instance to a Thread class accordingly line 10, when you call t.start() which in turns calls Runnable's Run Method, not Thread's Run method.