Consider the line, (new A(new B())).start();
When we create an instance of A and pass an instance of B to its constructor, we are creating a
Thread object from Runnable B (using the call to super),
but we're still calling start on Thread object A. And although we created our Thread object using Runnable B, the Thread object is A, and A has overridden Threads's run method.
If A did
not override run, then the parent (Thread's) version of run would be called. In the API for Thread's run method, it states, "If this thread was constructed using a separate Runnable run object, then that Runnable object's run method is called; otherwise, this method does nothing and returns." Therefore, because A was constructed using a separate Runnable object, B's run method would be called.
In other words,
Thread's run behavior is to use the Runnable's run method if a Runnable instance (B) is provided in the constructor. However, if run is overridden, then the overridden version of run (in A) is invoked rather than the version of run in the parent class Thread (which would invoke B's run).
[ September 14, 2004: Message edited by: marc weber ]