Question: how wait and notify works in java?
Answer: wait()-It tells the calling thread to give up the lock and go to sleep until some other thread enters the same monitor and calls notify().
notify()-It wakes up one single thread that called wait() on the same object. ... 
notifyAll()-It wakes up all the threads that called wait() on the same object.