Java TransferQueue

Last modified on November 9th, 2014 by Joe.

This Java tutorial is to learn about TransferQueue which is concurrent collection. TransferQueue is an interface and a type of BlockingQueue. TransferQueue extends from BlockingQueue interface to add behavior to it. In a TransferQueue producers may wait for consumers to receive elements. TransferQueue was added in Java SE 7.

This is marginally similar to the SynchronousQueue. In a SynchronousQueue the producer will always wait for a consumer. Once there is a consumer ready, the producer will push the item into the SynchrounousQueue and the item will be immediately consumed. So at any instance the queue length will always be zero.

In the case of TransferQueue, the producer with wait for the consumer to receive elements. The limit can be specified. Here the item can stay in the queue. This queue is useful in messaging applications. TransferQueue can be used as a pipeline to pass messages between channels.

Difference between BlockingQueue and TransferQueue

LinkedTransferQueue is an unbounded TranserQueue implementation available with the SDK.

Comments on "Java TransferQueue"

  1. […] was introduced in Java SE7 along with the TransferQueue. This queue is one of the most capable implementation in the concurrent collections. TransferQueue […]

Comments are closed for "Java TransferQueue".