As a result, it prints "A". But I can't figure out why! If I don't have the class MyThread and used Thread instead, the result would be "B". Does the run() method of a subclass of Thread have priority over the run() of the runnable passed as target to it? Ana
In the example given the run method is being over-ridden. The original run method in Thread calls the run method of the Runnable interface if the thread is passed a Runnable object. In this case the over-riding method changes the behaviour of the run method. It simply prints "A" and never calls the run method of the Runnable interface. As a result at run time the over-ridden run method is called and prints A.