Just because you have done b.start() does not mean that the run method will run immediately. The
Java Virtual Machine will decide when to run that
thread, and it may decide to let the main thread continue and grab the lock. You can give a hint to the JVM that b should run by setting a higher priority for thread b before you start it (no guarantee though), or you could make main yield the processor (again no guarantee), or you could make main sleep (again no guarantee, but at least a possibility), or you could make it join thread b.
Also there is the possibility that b does finish before the main thread waits, then the notify would be lost, and main would wait for ever.
What is the output you get?
[ December 11, 2004: Message edited by: Barry Gaunt ]