From 60d26a88c44b1a8dcdab337729588907d2474e42 Mon Sep 17 00:00:00 2001 From: Jack Tyler Date: Thu, 19 Feb 2026 17:34:59 +0200 Subject: [PATCH] Solution --- .../java/core/basesyntax/BlockingQueue.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/core/basesyntax/BlockingQueue.java b/src/main/java/core/basesyntax/BlockingQueue.java index 77a20440..ef8be8bf 100644 --- a/src/main/java/core/basesyntax/BlockingQueue.java +++ b/src/main/java/core/basesyntax/BlockingQueue.java @@ -12,16 +12,23 @@ public BlockingQueue(int capacity) { } public synchronized void put(T element) throws InterruptedException { - // write your code here + while (queue.size() == capacity) { + wait(); + } + queue.add(element); + notify(); + } public synchronized T take() throws InterruptedException { - // write your code here - return null; + while (isEmpty()) { + wait(); + } + notify(); + return queue.remove(); } public synchronized boolean isEmpty() { - // write your code here - return true; + return queue.isEmpty(); } }