public boolean addAll(int index,Collection<? extends E> c){
  Object[] cs=c.toArray();
  final ReentrantLock lock=this.lock;
  lock.lock();
  try {
    Object[] elements=getArray();
    int len=elements.length;
    if (index > len || index < 0)     throw new IndexOutOfBoundsException("Index: " + index + ", Size: "+ len);
    if (cs.length == 0)     return false;
    int numMoved=len - index;
    Object[] newElements;
    if (numMoved == 0)     newElements=Arrays.copyOf(elements,len + cs.length);
 else {
      newElements=new Object[len + cs.length];
      System.arraycopy(elements,0,newElements,0,index);
      System.arraycopy(elements,index,newElements,index + cs.length,numMoved);
    }
    System.arraycopy(cs,0,newElements,index,cs.length);
    setArray(newElements);
    return true;
  }
  finally {
    lock.unlock();
  }
}

public boolean addAll ( int index , Collection < ? extends E > c ) { Object [ ] cs = c . toArray ( ) ; final ReentrantLock lock = this . lock ; lock . lock ( ) ; try { Object [ ] elements = getArray ( ) ; int len = elements . length ; if ( index > len || index < 0 ) throw new IndexOutOfBoundsException ( "Index: " + index + ", Size: " + len ) ; if ( cs . length == 0 ) return false ; int numMoved = len - index ; Object [ ] newElements ; if ( numMoved == 0 ) newElements = Arrays . copyOf ( elements , len + cs . length ) ; else { newElements = new Object [ len + cs . length ] ; System . arraycopy ( elements , 0 , newElements , 0 , index ) ; System . arraycopy ( elements , index , newElements , index + cs . length , numMoved ) ; } System . arraycopy ( cs , 0 , newElements , index , cs . length ) ; setArray ( newElements ) ; return true ; } finally { lock . unlock ( ) ; } }
inserts all of the elements in the specified collection into this list , starting at the specified position . shifts the element currently at that position ( if any ) and any subsequent elements to the right ( increases their indices ) . the new elements will appear in this list in the order that they are returned by the specified collection ' s iterator .
