Please explain each part of the statement.
What does each part of the statement stand for especially Thread t? Why is it required.?
What does Thread.currentThread(); stand for and why is it required.
Thanks in advancee
It returns the reference to the current executing object of class Thread.
How do you want to call this reference to the current executing object of class Thread? Let's say t.
Thread t = Thread.currentThread();
After this statement t holds a reference to the current executing thread (i.e. the current executing object of class Thread).
Do you want to change the name to the reference? No problem. Let's say iAmTheCurrentThread
Thread iAmTheCurrentThread = Thread.currentThread();
ah..you asked why is required.
it's required because in multithreading programming you want to know what is the current thread executing, because you want interact with it, for example for changing its state, or getting its name,.
It isn't possible to move posts independent of threads, I am afraid. this is a reply to the question here.
Nicola Garofalo wrote:I think someone should move this post. (and my reply eheh )
Anyway, you override methods not member variables.
A a = new B();
you have an object of class A in hand (its name is a) , with overridden methods by B (none in this case)
The int value i belongs to A then and 10 is what you get on the output.
I hope it's more clear now.