Main program: Started
Main program: Spawing thread
Main program: Waiting for lock
Thread-0: Started
Thread-0: Starting for loop
Thread-0: Finished for loop.
Thread-0: About to notify all
Main program: Resuming.
Thread-0: Finished
Main program: Finished.

Notes:

wait( ) tells the calling thread to give up the monitor and go to sleep until some other thread enters the same monitor and calls notify( ).

notify( ) wakes up the first thread that called wait( ) on the same object.

notifyAll( ) wakes up all the threads that called wait( ) on the same object. The highest priority thread will run first.