Taken from K & B (
SCJP 1.6) page no.: 748 and 749:
This program contains two objects with threads: ThreadA contains the main
thread and ThreadB has a thread that calculates the sum of all numbers from 0
through 99. As soon as line 4 calls the start() method, ThreadA will continue
with the next line of code in its own class, which means it could get to line 11
before ThreadB has finished the calculation. To prevent this, we use the wait()
method in line 9.
Even it is stated that "As soon as line 4 calls the start() method, ThreadA will continue with the next line of code in its own class...". What I do not understand is, how can we be so sure?