LinkedTransferQueue is a TransferQueue, and SynchronousQueue is a BlockingQueue.

TransferQueue and BlockingQueue

BlockingQueue is a BlockingQueue that has a size. When the queue is full, the producer will block. When the queue is empty, consumers block.

TransferQueue adds a transfer method to BlockingQueue, which blocks the producer’s message only after it has been consumed.

SynchronousQueue VS LinkedTransferQueue

SynchronousQueue is a 0 BlockingQueue such that subsequent producers must wait as long as the message from the last queued producer has not been consumed. If you want to ensure producer sequencing, you need to set it to fair mode.

LinkedTransferQueue is a more efficient fair queue, mainly:

Optimizes bidirectional synchronous queue data structures and reduces update collisions by using CAS update references, avoiding locking data cache rows, reducing false sharing

Daily brush, easy to improve skills, get a variety of offers: