Hi Stephan,
The call to wait() may return at any moment, because of spurious wakeups.
I'm not sure what is meant by this. In given code, nobody is explicitly calling notify/notifyAll method on thread, so it is very very unlikely (rather I would say impossible) to get out of wait method before thread execution is finished. Once run method is executed, 'wait' will be over.
If I remove the thread.start() statement, the program runs indefinitely
This happened because, thread was not running, nobody's gonna ever call notify/notifyAll on that thread, and hence 'wait' will never end.
Hence, in my opinion, output should (and would) be 999999.
Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)