The thread that gets awakened as a result to a call to notify or notifyAll is implementation dependent. It is not guaranteed to be the thread that has been waiting the longest or has the highest priority. If you need to control the thread that gets awakened, I would suggest looking at Tom Cargill's Specific Notification
pattern at
http://www.sni.net/~cargill/jgf/9809/SpecificNotification.html Also, notifyAll will awaken all threads but only one will get the lock and execute, the others will block. When wait is called, the thread relinquishes its lock and goes into a wait state. When notifyAll is called, all threads waiting on the lock are awakened, but only one gets the lock...and without special code like in the pattern above, you can't determine which thread that will be.
Peter Haggar
------------------
author of:
Practical Java