code: private void checkIndices(int row, int col, boolean expand) {
           if (row < 0 || col < 0) {
               throw new ArrayIndexOutOfBoundsException();
           }
           if (expand) {
               int r = row + 1;
               int cur = 0;
               while (r > (cur = rows.get()) && !rows.compareAndSet(cur, r))
                   ;
               int c = col + 1;
               cur = 0;
               while (c > (cur = cols.get()) && !cols.compareAndSet(cur, c))
                   ;
           }
      }
docs: Verify that the given row and column value is non-negative, and
  optionally expand the size of the matrix if the row or column are outside
  the current bounds.
  
  @param row the row index to check.
  @param the the column index to check.
  @param expand {@code true} if the current dimensions of the matrix should
  be updated if either parameter exceeds the current values