When you call the .start method of a Thread class, according to the JavaDoc: [calling the start method] causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread So, the run method will be called. Since A's start method is used and A's run method prints A, A is printed. The runnable passed to A's constructor has no effect.
SCJP 1.4, SCWCD 1.4, SCBCD 1.3
Joined: Jan 09, 2004
Thanks Pang Please could the execution of the code, be explained more clearly.I am still confused.
maybe you could look at the Thread.java. You will see that the run method there looks like this :
And when start of the thread is invoked it will do the run() method. And you overridden the run() method in the original thread. So it won't execute the 'target' but only your run method. Look in the source of java wich comes with every SDK. I hope this helps greeting Jos ( who is has to take his exam april the 6th ) [ April 02, 2004: Message edited by: j zaal ]