SynchronousQueue Class

Definition

A BlockingQueue blocking queue in which each insert operation must wait for a corresponding remove operation by another thread, and vice versa.

[Android.Runtime.Register("java/util/concurrent/SynchronousQueue", DoNotGenerateAcw=true)]
[Java.Interop.JavaTypeParameters(new System.String[] { "E" })]
public class SynchronousQueue : Java.Util.AbstractQueue, IDisposable, Java.Interop.IJavaPeerable, Java.IO.ISerializable, Java.Util.Concurrent.IBlockingQueue
[<Android.Runtime.Register("java/util/concurrent/SynchronousQueue", DoNotGenerateAcw=true)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "E" })>]
type SynchronousQueue = class
    inherit AbstractQueue
    interface ISerializable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
    interface IBlockingQueue
    interface IQueue
    interface ICollection
    interface IIterable
Inheritance
Attributes
Implements

Remarks

A BlockingQueue 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 <em>head</em> 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 <em>optional</em> methods of the Collection and Iterator interfaces.

This class is a member of the Java Collections Framework.

Added in 1.5.

Java documentation for java.util.concurrent.SynchronousQueue.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

SynchronousQueue()

Creates a SynchronousQueue with nonfair access policy.

SynchronousQueue(Boolean)

Creates a SynchronousQueue with the specified fairness policy.

SynchronousQueue(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsEmpty

To be added

(Inherited from AbstractCollection)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

Add(Object)

To be added

(Inherited from AbstractCollection)
AddAll(ICollection)

To be added

(Inherited from AbstractCollection)
Clear()

To be added

(Inherited from AbstractCollection)
Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Contains(Object)

To be added

(Inherited from AbstractCollection)
ContainsAll(ICollection)

To be added

(Inherited from AbstractCollection)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
DrainTo(ICollection)
DrainTo(ICollection, Int32)
Element()

Retrieves, but does not remove, the head of this queue.

(Inherited from AbstractQueue)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
Iterator()

Returns an empty iterator in which hasNext always returns false.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Offer(Object)

Inserts the specified element into this queue, if another thread is waiting to receive it.

Offer(Object, Int64, TimeUnit)

Inserts the specified element into this queue, waiting if necessary up to the specified wait time for another thread to receive it.

Peek()

Always returns null.

Poll()

Retrieves and removes the head of this queue, if another thread is currently making an element available.

Poll(Int64, TimeUnit)

Retrieves and removes the head of this queue, waiting if necessary up to the specified wait time, for another thread to insert it.

Put(Object)

Adds the specified element to this queue, waiting if necessary for another thread to receive it.

RemainingCapacity()

Always returns zero.

Remove()

Retrieves and removes the head of this queue.

(Inherited from AbstractQueue)
Remove(Object)

To be added

(Inherited from AbstractCollection)
RemoveAll(ICollection)

To be added

(Inherited from AbstractCollection)
RetainAll(ICollection)

To be added

(Inherited from AbstractCollection)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
Size()

Always returns zero.

Spliterator()

Returns an empty spliterator in which calls to Spliterator#trySplit() trySplit always return null.

Take()

Retrieves and removes the head of this queue, waiting if necessary for another thread to insert it.

ToArray()

To be added

(Inherited from AbstractCollection)
ToArray(Object[])

To be added

(Inherited from AbstractCollection)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)
OfferAsync(IBlockingQueue, Object)
OfferAsync(IBlockingQueue, Object, Int64, TimeUnit)
PollAsync(IBlockingQueue, Int64, TimeUnit)
PutAsync(IBlockingQueue, Object)
TakeAsync(IBlockingQueue)
ToEnumerable(IIterable)
ToEnumerable<T>(IIterable)

Applies to