A java.util.concurrent.blocking queue in which each insert operation must wait for a corresponding remove operation by another thread, and vice versa. A synchronous queue does not have any internal capacity, not even a capacity of one. You cannot peek at a synchronous queue because an element is only present when you try to remove it; you cannot insert an element (using any method) unless another thread is trying to remove it; you cannot iterate as there is nothing to iterate. The head of the queue is the element that the first queued inserting thread is trying to add to the queue; if there is no such queued thread then no element is available for removal and poll() will return null. For purposes of other Collection methods (for example contains), a SynchronousQueue acts as an empty collection. This queue does not permit null elements.
Synchronous queues are similar to rendezvous channels used in CSP and Ada. They are well suited for handoff designs, in which an object running in one thread must sync up with an object running in another thread in order to hand it some information, event, or task.
This class supports an optional fairness policy for ordering waiting producer and consumer threads. By default, this ordering is not guaranteed. However, a queue constructed with fairness set to true grants threads access in FIFO order.
This class and its iterator implement all of the optional methods of the Collection and Iterator interfaces.
This class is a member of the
Java Collections Framework.
A java.util.concurrent.blocking queue in which each insert operation must wait for a corresponding remove operation by another thread, and vice versa. A synchronous queue does not have any internal capacity, not even a capacity of one. You cannot peek at a synchronous queue because an element is only present when you try to remove it; you cannot insert an element (using any method) unless another thread is trying to remove it; you cannot iterate as there is nothing to iterate. The head of the queue is the element that the first queued inserting thread is trying to add to the queue; if there is no such queued thread then no element is available for removal and poll() will return null. For purposes of other Collection methods (for example contains), a SynchronousQueue acts as an empty collection. This queue does not permit null elements. Synchronous queues are similar to rendezvous channels used in CSP and Ada. They are well suited for handoff designs, in which an object running in one thread must sync up with an object running in another thread in order to hand it some information, event, or task. This class supports an optional fairness policy for ordering waiting producer and consumer threads. By default, this ordering is not guaranteed. However, a queue constructed with fairness set to true grants threads access in FIFO order. This class and its iterator implement all of the optional methods of the Collection and Iterator interfaces. This class is a member of the Java Collections Framework.
(->synchronous-queue)
(->synchronous-queue fair)
Constructor.
Creates a SynchronousQueue with the specified fairness policy.
fair - if true, waiting threads contend in FIFO order for access; otherwise the order is unspecified. - boolean
Constructor. Creates a SynchronousQueue with the specified fairness policy. fair - if true, waiting threads contend in FIFO order for access; otherwise the order is unspecified. - `boolean`
(clear this)
Does nothing. A SynchronousQueue has no internal capacity.
Does nothing. A SynchronousQueue has no internal capacity.
(contains this o)
Always returns false. A SynchronousQueue has no internal capacity.
o - the element - java.lang.Object
returns: false - boolean
Always returns false. A SynchronousQueue has no internal capacity. o - the element - `java.lang.Object` returns: false - `boolean`
(contains-all this c)
Returns false unless the given collection is empty. A SynchronousQueue has no internal capacity.
c - the collection - java.util.Collection
returns: false unless given collection is empty - boolean
Returns false unless the given collection is empty. A SynchronousQueue has no internal capacity. c - the collection - `java.util.Collection` returns: false unless given collection is empty - `boolean`
(drain-to this c)
(drain-to this c max-elements)
Description copied from interface: BlockingQueue
c - the collection to transfer elements into - java.util.Collection
max-elements - the maximum number of elements to transfer - int
returns: the number of elements transferred - int
throws: java.lang.UnsupportedOperationException - if addition of elements is not supported by the specified collection
Description copied from interface: BlockingQueue c - the collection to transfer elements into - `java.util.Collection` max-elements - the maximum number of elements to transfer - `int` returns: the number of elements transferred - `int` throws: java.lang.UnsupportedOperationException - if addition of elements is not supported by the specified collection
(empty? this)
Always returns true. A SynchronousQueue has no internal capacity.
returns: true - boolean
Always returns true. A SynchronousQueue has no internal capacity. returns: true - `boolean`
(iterator this)
Returns an empty iterator in which hasNext always returns false.
returns: an empty iterator - java.util.Iterator<E>
Returns an empty iterator in which hasNext always returns false. returns: an empty iterator - `java.util.Iterator<E>`
(offer this e)
(offer this e timeout unit)
Inserts the specified element into this queue, waiting if necessary up to the specified wait time for another thread to receive it.
e - the element to add - E
timeout - how long to wait before giving up, in units of unit - long
unit - a TimeUnit determining how to interpret the timeout parameter - java.util.concurrent.TimeUnit
returns: true if successful, or false if the
specified waiting time elapses before a consumer appears - boolean
throws: java.lang.InterruptedException - if interrupted while waiting
Inserts the specified element into this queue, waiting if necessary up to the specified wait time for another thread to receive it. e - the element to add - `E` timeout - how long to wait before giving up, in units of unit - `long` unit - a TimeUnit determining how to interpret the timeout parameter - `java.util.concurrent.TimeUnit` returns: true if successful, or false if the specified waiting time elapses before a consumer appears - `boolean` throws: java.lang.InterruptedException - if interrupted while waiting
(peek this)
Always returns null. A SynchronousQueue does not return elements unless actively waited on.
returns: null - E
Always returns null. A SynchronousQueue does not return elements unless actively waited on. returns: null - `E`
(poll this)
(poll this timeout unit)
Retrieves and removes the head of this queue, waiting if necessary up to the specified wait time, for another thread to insert it.
timeout - how long to wait before giving up, in units of unit - long
unit - a TimeUnit determining how to interpret the timeout parameter - java.util.concurrent.TimeUnit
returns: the head of this queue, or null if the
specified waiting time elapses before an element is present - E
throws: java.lang.InterruptedException - if interrupted while waiting
Retrieves and removes the head of this queue, waiting if necessary up to the specified wait time, for another thread to insert it. timeout - how long to wait before giving up, in units of unit - `long` unit - a TimeUnit determining how to interpret the timeout parameter - `java.util.concurrent.TimeUnit` returns: the head of this queue, or null if the specified waiting time elapses before an element is present - `E` throws: java.lang.InterruptedException - if interrupted while waiting
(put this e)
Adds the specified element to this queue, waiting if necessary for another thread to receive it.
e - the element to add - E
throws: java.lang.InterruptedException - if interrupted while waiting
Adds the specified element to this queue, waiting if necessary for another thread to receive it. e - the element to add - `E` throws: java.lang.InterruptedException - if interrupted while waiting
(remaining-capacity this)
Always returns zero. A SynchronousQueue has no internal capacity.
returns: zero - int
Always returns zero. A SynchronousQueue has no internal capacity. returns: zero - `int`
(remove this o)
Always returns false. A SynchronousQueue has no internal capacity.
o - the element to remove - java.lang.Object
returns: false - boolean
Always returns false. A SynchronousQueue has no internal capacity. o - the element to remove - `java.lang.Object` returns: false - `boolean`
(remove-all this c)
Always returns false. A SynchronousQueue has no internal capacity.
c - the collection - java.util.Collection
returns: false - boolean
Always returns false. A SynchronousQueue has no internal capacity. c - the collection - `java.util.Collection` returns: false - `boolean`
(retain-all this c)
Always returns false. A SynchronousQueue has no internal capacity.
c - the collection - java.util.Collection
returns: false - boolean
Always returns false. A SynchronousQueue has no internal capacity. c - the collection - `java.util.Collection` returns: false - `boolean`
(size this)
Always returns zero. A SynchronousQueue has no internal capacity.
returns: zero - int
Always returns zero. A SynchronousQueue has no internal capacity. returns: zero - `int`
(spliterator this)
Returns an empty spliterator in which calls to Spliterator.trySplit() always return null.
returns: an empty spliterator - java.util.Spliterator<E>
Returns an empty spliterator in which calls to Spliterator.trySplit() always return null. returns: an empty spliterator - `java.util.Spliterator<E>`
(take this)
Retrieves and removes the head of this queue, waiting if necessary for another thread to insert it.
returns: the head of this queue - E
throws: java.lang.InterruptedException - if interrupted while waiting
Retrieves and removes the head of this queue, waiting if necessary for another thread to insert it. returns: the head of this queue - `E` throws: java.lang.InterruptedException - if interrupted while waiting
(to-array this)
(to-array this a)
Sets the zeroeth element of the specified array to null (if the array has non-zero length) and returns it.
a - the array - T[]
returns: the specified array - <T> T[]
throws: java.lang.NullPointerException - if the specified array is null
Sets the zeroeth element of the specified array to null (if the array has non-zero length) and returns it. a - the array - `T[]` returns: the specified array - `<T> T[]` throws: java.lang.NullPointerException - if the specified array is null
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close