I have 2 questions.
Q1. now the definition of wait() function is like this : tells the calling
thread to give up monitor and go to sleep until some other thread enters the same monitor and calls notify().
Now in this program two threads(One related to consumer and one to producer) use the same object q in get and put respectively. So is there only one monitor existing for the object q, which is entered when any thread uses a function involving q?
Q2 Here the Consumer waits until Producer notifies it, but the Producer also waits until the consumer notifies it? Who starts first?
In the output, Producer comes first but how?