code: protected synchronized boolean cancel(Object x) {
          synchronized (lock) {
              if (putIndex > takeIndex) {
                  for (int i = takeIndex; i < putIndex; i++) {
                      if (buffer[i] == x) {
                          System.arraycopy(buffer, i + 1, buffer, i, putIndex - i - 1);
                          putIndex--;
                          buffer[putIndex] = null;
                          numberOfUsedSlots.getAndDecrement(); // D615053
                          return true;
                      }
                  }
              } else if (putIndex != takeIndex || buffer[takeIndex] != null) {
                  for (int i = takeIndex; i < buffer.length; i++) {
                      if (buffer[i] == x) {
                          if (i != buffer.length - 1) {
                              System.arraycopy(buffer, i + 1, buffer, i, buffer.length - i - 1);
                          }
  
                          if (putIndex != 0) {
                              buffer[buffer.length - 1] = buffer[0];
                              System.arraycopy(buffer, 1, buffer, 0, putIndex - 1);
                              putIndex--;
                          } else {
                              putIndex = buffer.length - 1;
                          }
  
                          buffer[putIndex] = null;
                          numberOfUsedSlots.getAndDecrement(); // D615053
                          return true;
                      }
                  }
  
                  // D610567 - Scan first section of BoundedBuffer
                  for (int i = 0; i < putIndex; i++) {
                      if (buffer[i] == x) {
                          System.arraycopy(buffer, i + 1, buffer, i, putIndex - i - 1);
                          putIndex--;
                          buffer[putIndex] = null;
                          numberOfUsedSlots.getAndDecrement(); // D615053
                          return true;
                      }
                  }
  
              }
          }
  
          return false;
      }
docs: F743-12896 - Start