My Doubt is "How the Thread object refernce(th) used to call the MyRunnable's method run()?",Please Explain? I agree that its legal to call run() method directly on Thread instance and Runnable Implementation Instance.
Joined: Feb 15, 2007
Thread th=new Thread(new MyRunnable());
step 1> new MyRunnable() will create an object of MyRunnable. Note: Through runnable you can explicitly mention "Thread of excecution".
step 2> new Thread(new MyRunnable());
without Thread Object there is no use of Thread of execution. Now thread object initialyzed with new "Thread of excution".
step 3> Thread th=new Thread(new MyRunnable()); I got another doubt: th.run() should call the default run method in Thread(i expected..> but Runnable run() executed? How it blocking default run()?) th.start() should call the Runnable run()( this is ok, becuase In start method it can check for Runnable Object and call its run())
Note: Thread object contains default run() method which does nothing. If you don't provide a seperate "thread of execution" through Runnable, then the default one will get called