@Override
    public boolean remove(Object o) {
        final ReentrantLock lock = this.lock;
        lock.lock();
        try {
            Object[] elements = getArray();
            int len = elements.length;
            if (len != 0) {
                // Copy while searching for element to remove
                // This wins in the normal case of element being present
                int newlen = len - 1;
                Object[] newElements = new Object[newlen];

                for (int i = 0; i < newlen; ++i) {
                    if (eq(o, elements[i])) {
                        // found one;  copy remaining and exit
                        for (int k = i + 1; k < len; ++k)
                            newElements[k - 1] = elements[k];
                        setArray(newElements);
                        return true;
                    } else
                        newElements[i] = elements[i];
                }

                // special handling for last cell
                if (eq(o, elements[newlen])) {
                    setArray(newElements);
                    return true;
                }
            }
            return false;
        } finally {
            lock.unlock();
        }
    }
@ Override public boolean remove ( Object o ) { final ReentrantLock lock = this . lock ; lock . lock ( ) ; try { Object [ ] elements = getArray ( ) ; int len = elements . length ; if ( len != 0 ) { int newlen = len - 1 ; Object [ ] newElements = new Object [ newlen ] ; for ( int i = 0 ; i < newlen ; ++ i ) { if ( eq ( o , elements [ i ] ) ) { for ( int k = i + 1 ; k < len ; ++ k ) newElements [ k - 1 ] = elements [ k ] ; setArray ( newElements ) ; return true ; } else newElements [ i ] = elements [ i ] ; } if ( eq ( o , elements [ newlen ] ) ) { setArray ( newElements ) ; return true ; } } return false ; } finally { lock . unlock ( ) ; } }
Removes the first occurrence of the specified element from this list,
if it is present. If this list does not contain the element, it is
unchanged. More formally, removes the element with the lowest index
<tt>i</tt> such that
<tt>(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i)))</tt>
(if such an element exists). Returns <tt>true</tt> if this list
contained the specified element (or equivalently, if this list
changed as a result of the call).

@param o element to be removed from this list, if present
@return <tt>true</tt> if this list contained the specified element