Skip to content

Commit 5da9597

Browse files
authored
Update WaitNotifyPipeline.java
1 parent 2c69c8b commit 5da9597

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pipeline/WaitNotifyPipeline.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public WaitNotifyPipeline(int maxCapacity)
1717

1818
public synchronized Message receive() throws InterruptedException
1919
{
20-
if (messageQueue.isEmpty())
20+
while (messageQueue.isEmpty())
2121
this.wait();
2222
Message retVal = messageQueue.poll();
2323
this.notify();
@@ -26,7 +26,7 @@ public synchronized Message receive() throws InterruptedException
2626

2727
public synchronized void send(Message message) throws InterruptedException
2828
{
29-
if (messageQueue.size() == maxCapacity)
29+
while (messageQueue.size() == maxCapacity)
3030
this.wait();
3131
messageQueue.add(message);
3232
this.notify();

0 commit comments

Comments
 (0)