This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Originally posted by Tony William: correct me if I am wrong.
In the sample code, there is actually one thread running (ignoring the main program thread). As a result, the mentioned result is expected.
In case we have 2 or more thread, then the result will depend on the JVM's thread scheduler (as pointed out by Steve).
The result is not expected. Maybe I should say the result is not certain. You can't be sure for how many times the for loop will get iterated before System.out.println is called by the main; it still depends on the JVM thread scheduler.
Joined: Nov 22, 2002
Thanks for the reply. Can anybody tell me where I can find proper tutorial on Thread? ARathi