class ByteBufferAllocator {

    // size of each Buffer
    final int capacity;
    // max num of Buffers
    final int maxCount;
    final BlockingQueue<ByteBuffer> freeQueue = new LinkedBlockingQueue<>();
    // current num of Buffers in queue
    AtomicInteger totalCount;

    public ByteBufferAllocator(int cap, int count) {
        this.capacity = cap;
        this.maxCount = count;
        this.totalCount = new AtomicInteger(0);
    }

    public ByteBuffer get() throws InterruptedException {<FILL_FUNCTION_BODY>}

    public void release(ByteBuffer buffer) {
        if (freeQueue.size() < maxCount) {
            buffer.clear();
            freeQueue.add(buffer);
        }
    }
}

        ByteBuffer buffer = null;
        while (buffer == null) {
            if (freeQueue.size() > 0) {
                buffer = freeQueue.poll();
            } else if (totalCount.get() < maxCount) {
                buffer = ByteBuffer.allocate(capacity);
                totalCount.incrementAndGet();
            } else {
                buffer = freeQueue.poll(1, TimeUnit.SECONDS);
            }
        }
        return buffer;
    
<no_super_class>