jdk/src/share/classes/java/util/concurrent/LinkedBlockingQueue.java
changeset 19428 83f87aff7b07
parent 18767 6214297bf27d
equal deleted inserted replaced
19427:5be308124a22 19428:83f87aff7b07
   764 
   764 
   765     /**
   765     /**
   766      * Returns an iterator over the elements in this queue in proper sequence.
   766      * Returns an iterator over the elements in this queue in proper sequence.
   767      * The elements will be returned in order from first (head) to last (tail).
   767      * The elements will be returned in order from first (head) to last (tail).
   768      *
   768      *
   769      * <p>The returned iterator is a "weakly consistent" iterator that
   769      * <p>The returned iterator is
   770      * will never throw {@link java.util.ConcurrentModificationException
   770      * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
   771      * ConcurrentModificationException}, and guarantees to traverse
       
   772      * elements as they existed upon construction of the iterator, and
       
   773      * may (but is not guaranteed to) reflect any modifications
       
   774      * subsequent to construction.
       
   775      *
   771      *
   776      * @return an iterator over the elements in this queue in proper sequence
   772      * @return an iterator over the elements in this queue in proper sequence
   777      */
   773      */
   778     public Iterator<E> iterator() {
   774     public Iterator<E> iterator() {
   779         return new Itr();
   775         return new Itr();
   971             return Spliterator.ORDERED | Spliterator.NONNULL |
   967             return Spliterator.ORDERED | Spliterator.NONNULL |
   972                 Spliterator.CONCURRENT;
   968                 Spliterator.CONCURRENT;
   973         }
   969         }
   974     }
   970     }
   975 
   971 
       
   972     /**
       
   973      * Returns a {@link Spliterator} over the elements in this queue.
       
   974      *
       
   975      * <p>The returned spliterator is
       
   976      * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
       
   977      *
       
   978      * <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT},
       
   979      * {@link Spliterator#ORDERED}, and {@link Spliterator#NONNULL}.
       
   980      *
       
   981      * @implNote
       
   982      * The {@code Spliterator} implements {@code trySplit} to permit limited
       
   983      * parallelism.
       
   984      *
       
   985      * @return a {@code Spliterator} over the elements in this queue
       
   986      * @since 1.8
       
   987      */
   976     public Spliterator<E> spliterator() {
   988     public Spliterator<E> spliterator() {
   977         return new LBQSpliterator<E>(this);
   989         return new LBQSpliterator<E>(this);
   978     }
   990     }
   979 
   991 
   980     /**
   992     /**
   981      * Saves this queue to a stream (that is, serializes it).
   993      * Saves this queue to a stream (that is, serializes it).
   982      *
   994      *
       
   995      * @param s the stream
       
   996      * @throws java.io.IOException if an I/O error occurs
   983      * @serialData The capacity is emitted (int), followed by all of
   997      * @serialData The capacity is emitted (int), followed by all of
   984      * its elements (each an {@code Object}) in the proper order,
   998      * its elements (each an {@code Object}) in the proper order,
   985      * followed by a null
   999      * followed by a null
   986      */
  1000      */
   987     private void writeObject(java.io.ObjectOutputStream s)
  1001     private void writeObject(java.io.ObjectOutputStream s)
  1003         }
  1017         }
  1004     }
  1018     }
  1005 
  1019 
  1006     /**
  1020     /**
  1007      * Reconstitutes this queue from a stream (that is, deserializes it).
  1021      * Reconstitutes this queue from a stream (that is, deserializes it).
       
  1022      * @param s the stream
       
  1023      * @throws ClassNotFoundException if the class of a serialized object
       
  1024      *         could not be found
       
  1025      * @throws java.io.IOException if an I/O error occurs
  1008      */
  1026      */
  1009     private void readObject(java.io.ObjectInputStream s)
  1027     private void readObject(java.io.ObjectInputStream s)
  1010         throws java.io.IOException, ClassNotFoundException {
  1028         throws java.io.IOException, ClassNotFoundException {
  1011         // Read in capacity, and any hidden stuff
  1029         // Read in capacity, and any hidden stuff
  1012         s.defaultReadObject();
  1030         s.defaultReadObject();