private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
  lock.lock();
  try {
    q=new PriorityQueue<E>(Math.max(size,1),comparator);
    q.addAll(this);
    s.defaultWriteObject();
  }
  finally {
    q=null;
    lock.unlock();
  }
}

private void writeObject ( java . io . ObjectOutputStream s ) throws java . io . IOException { lock . lock ( ) ; try { q = new PriorityQueue < E > ( Math . max ( size , 1 ) , comparator ) ; q . addAll ( this ) ; s . defaultWriteObject ( ) ; } finally { q = null ; lock . unlock ( ) ; } }
saves this queue to a stream ( that is , serializes it ) . for compatibility with previous version of this class , elements are first copied to a java . util . priorityqueue , which is then serialized .
