docs: public void setCapacity(int capacity) {
          if (capacity <= 0) {
              throw new IllegalArgumentException("capacity must be greater than 0");
          }
  
          synchronized (queue) {
              // If the capacity was reduced, we remove oldest elements until the
              // queue fits inside the specified capacity
              if (capacity < this.capacity) {
                  while (queue.size() > capacity) {
                      queue.removeFirst();
                  }
              }
          }
  
          this.capacity = capacity;
      }