Brandon Tom, SCJP, MCP<br />Programmer/Graphic Designer<br /><a href="http://mailto:tombrand@hawaii.edu" target="_blank" rel="nofollow">tombrand@hawaii.edu</a>
Parallax - Change in observational position that provides a new line of sight.
OK, let`s go back to the main problem. Assume it ends invocation and goes back to main.
Now it can execute line 6 and print "vandeleur", then move to thread of execution t, and do the for loop, but there`s no another print statement to print static String sName variable, so the output is "vandeleur".
Originally posted by rammmmm reddy:
The answer is "vandeleur":
Because you are modifying String object in Run() method..But the you are not printing anything there..So your original object will not be modified..If you are printing inside the run() method ,the fourth answeris correct one.
"Strings are immutable"
Originally posted by rammmmm reddy:
The answer is "vandeleur":
Because you are modifying String object in Run() method..But the you are not printing anything there..So your original object will not be modified..If you are printing inside the run() method ,the fourth answeris correct one.
"Strings are immutable"
Originally posted by Faqeer Khudaka:
Hi Aleksander,
Threads are a bit confusing for me.
Could you please clarify how after the method invocation and after line 9 the for loop is not completely executed and why the output is not "vandeleur 0 1 2 3" only .
Second question, how can after thread t has started we move back and forth between the for loop and the main?
Thanks for your time.
I have always wanted to have a neighbor just like you - Fred Rogers. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|