@Override
    public void push(T task) throws IllegalArgumentException, InterruptedException {
        if (task == null) {
            throw new IllegalArgumentException("Task shall not be null");
        }

        boolean isAdded = false;
        while (!isAdded) {
            int currentSize;
            synchronized (taskQueue) {
                currentSize = taskQueue.size();
                if (currentSize < maxSize) {
                    isAdded = true;
                    taskQueue.addLast(task);
                    taskQueue.notify();
                }
            }

            if (!isAdded) {
                waitForSizeLowerThan(currentSize - maxSize / 2 + 1);
            }
        }
    }