diff --git a/src/main/java/core/basesyntax/BlockingQueue.java b/src/main/java/core/basesyntax/BlockingQueue.java index 77a20440..30b31b9c 100644 --- a/src/main/java/core/basesyntax/BlockingQueue.java +++ b/src/main/java/core/basesyntax/BlockingQueue.java @@ -12,16 +12,22 @@ 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(); + } + notifyAll(); + return queue.poll(); } public synchronized boolean isEmpty() { - // write your code here - return true; + return queue.isEmpty(); } }