public Object[] toArray(){
  fullyLock();
  try {
    int size=count.get();
    Object[] a=new Object[size];
    int k=0;
    for (Node<E> p=head.next; p != null; p=p.next)     a[k++]=p.item;
    return a;
  }
  finally {
    fullyUnlock();
  }
}

public Object [ ] toArray ( ) { fullyLock ( ) ; try { int size = count . get ( ) ; Object [ ] a = new Object [ size ] ; int k = 0 ; for ( Node < E > p = head . next ; p != null ; p = p . next ) a [ k ++ ] = p . item ; return a ; } finally { fullyUnlock ( ) ; } }
returns an array containing all of the elements in this queue , in proper sequence . < p > the returned array will be " safe " in that no references to it are maintained by this queue . ( in other words , this method must allocate a new array ) . the caller is thus free to modify the returned array . < p > this method acts as bridge between array - based and collection - based apis .
