I have a question, if you closly the implementation using wait and notify method it is not exactly doing what blocking queue is doing, so I thing blocking queue is working Asynchronously where as wait and notify is working synchronously as we have added synchronized block over the shared resources, So basically I want to say if you look output of wait-notify method there always will be goring phase of the buffer sequaltially and once it reach the limit then shrinking phase of the buffer start sequentially and again growing phase vice-versa, but in the case of BlockingQueue the growing and shrinking phase of the queue is not sequential it is parallel. So how can we achieve that using wait and notify method approach, batter I would how BlockingQueue is achieving this kind of concurrent way of updatating the buffer.
@LazzyProgrammer6 ай бұрын
Blocking Queue handles concurrent updates to the buffer by allowing multiple threads to interact with the queue simultaneously without the need for explicit synchronization. It internally handles synchronization. Using wait and notify it's sequential order within synchronized blocks, where one thread must wait for another to release the lock before proceeding.