The semantics of wait () is that the calling thread pays attention to the fact that the lock has already been received by another thread, pauses and waits for a notification from the thread holding the lock when the latter releases it (and calls the notification), This does not mean that when pending it releases all acquired locks. You can see the waiting challenges as a series of obstacles that the thread faces on the path to acquiring all the locks needed to complete the action.
Regarding the question βWhy does a thread not release all the locks received by calling waitβ, I think the answer is that it will make it more prone to hunger, and it will also slow down progress in a multi-threaded application (all threads will discard all their locks on first call and will have to start when they get the lock they are currently waiting for, so they will be in constant battle for locks. In fact, in such a system, the only thread that can complete execution e, there will be one that can find all the locks for free when they need it. This is unlikely to happen)
source share