ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/SynchronousQueue.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/SynchronousQueue.java (file contents):
Revision 1.51 by jsr166, Tue May 17 16:16:01 2005 UTC vs.
Revision 1.52 by jsr166, Wed May 18 19:05:07 2005 UTC

# Line 9 | Line 9 | import java.util.concurrent.locks.*;
9   import java.util.*;
10  
11   /**
12 < * A {@linkplain BlockingQueue blocking queue} in which each
13 < * <tt>put</tt> must wait for a <tt>take</tt>, and vice versa.  A
14 < * synchronous queue does not have any internal capacity, not even a
15 < * capacity of one.  You cannot <tt>peek</tt> at a synchronous queue
16 < * because an element is only present when you try to take it; you
17 < * cannot add an element (using any method) unless another thread is
18 < * trying to remove it; you cannot iterate as there is nothing to
19 < * iterate.  The <em>head</em> of the queue is the element that the
20 < * first queued thread is trying to add to the queue; if there are no
21 < * queued threads then no element is being added and the head is
22 < * <tt>null</tt>.  For purposes of other <tt>Collection</tt> methods
23 < * (for example <tt>contains</tt>), a <tt>SynchronousQueue</tt> acts
24 < * as an empty collection.  This queue does not permit <tt>null</tt>
25 < * elements.
12 > * A {@linkplain BlockingQueue blocking queue} in which each insert
13 > * operation must wait for a corresponding remove operation by another
14 > * thread, and vice versa.  A synchronous queue does not have any
15 > * internal capacity, not even a capacity of one.  You cannot
16 > * <tt>peek</tt> at a synchronous queue because an element is only
17 > * present when you try to remove it; you cannot insert an element
18 > * (using any method) unless another thread is trying to remove it;
19 > * you cannot iterate as there is nothing to iterate.  The
20 > * <em>head</em> of the queue is the element that the first queued
21 > * inserting thread is trying to add to the queue; if there is no such
22 > * queued thread then no element is available for removal and
23 > * <tt>poll()</tt> will return <tt>null</tt>.  For purposes of other
24 > * <tt>Collection</tt> methods (for example <tt>contains</tt>), a
25 > * <tt>SynchronousQueue</tt> acts as an empty collection.  This queue
26 > * does not permit <tt>null</tt> elements.
27   *
28   * <p>Synchronous queues are similar to rendezvous channels used in
29   * CSP and Ada. They are well suited for handoff designs, in which an

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines