notify() sends a signal to one and only one of the threads that are waiting in that same object's waiting pool.
notify() method can NOT specify which waiting thread to notify.
If more than one Thread is waiting, the programmer cannot control which one will be returned to the runnable when notify is called.
You can use notifyAll to nofity more than one threads.
The notifyAll call removes all waiting Threads from the wait list.
Only one of these actually gets a lock on the object and is allowed to execute the synchronized method.
If a Thread that does not have a lock on an object attempts to call the object's wait or notify method, an IllegalMonitorStateException is thrown.
Your calls to wait or notify or notifyAll should be in synchronized code blocks.