From 90183dbc6da9229f5216ef1cedc50fcfdcfc5e85 Mon Sep 17 00:00:00 2001 From: Vitaliy Tishik Date: Fri, 13 Mar 2026 19:16:35 +0200 Subject: [PATCH] fix --- .../java/core/basesyntax/BlockingQueue.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/core/basesyntax/BlockingQueue.java b/src/main/java/core/basesyntax/BlockingQueue.java index 77a20440..e2607a51 100644 --- a/src/main/java/core/basesyntax/BlockingQueue.java +++ b/src/main/java/core/basesyntax/BlockingQueue.java @@ -12,16 +12,26 @@ public BlockingQueue(int capacity) { } public synchronized void put(T element) throws InterruptedException { - // write your code here + while (queue.size() == capacity) { + wait(); + } + + queue.add(element); + notifyAll(); } public synchronized T take() throws InterruptedException { - // write your code here - return null; + while (queue.isEmpty()) { + wait(); + } + + T value = queue.poll(); + + notifyAll(); + return value; } public synchronized boolean isEmpty() { - // write your code here - return true; + return queue.isEmpty(); } }