public Object[] toArray(){
  final ReentrantLock lock=this.lock;
  lock.lock();
  try {
    Object[] arr=new Object[size];
    int i=0;
    for (    TenantQueue q : qs.values()) {
      Object[] qarr=q.toArray();
      System.arraycopy(qarr,0,arr,i,qarr.length);
      i+=qarr.length;
    }
    return arr;
  }
  finally {
    lock.unlock();
  }
}

public Object [ ] toArray ( ) { final ReentrantLock lock = this . lock ; lock . lock ( ) ; try { Object [ ] arr = new Object [ size ] ; int i = 0 ; for ( TenantQueue q : qs . values ( ) ) { Object [ ] qarr = q . toArray ( ) ; System . arraycopy ( qarr , 0 , arr , i , qarr . length ) ; i += qarr . length ; } return arr ; } finally { lock . unlock ( ) ; } }
returns an array containing all of the elements in this queue . the returned array elements are in no particular order . < 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 .
