LinkedTransferQueue in Java

Last Updated : 11 Jul, 2025

In Java, the LinkedTransferQueue is a part of the java.util.concurrent package and implements the TransferQueue. It is specifically designed for handling concurrent data transfers. It is a non-blocking, thread-safe, unbounded queue that supports both producer-consumer and transfer operations, making it suitable for high-performance, multi-threaded applications.

  • Most of its methods are non-blocking, offering thread-safe operations without locking.
  • It can grow dynamically to accommodate more elements without any predefined limit.
  • Optimized for high-throughput and low-latency transfers in multi-threaded environments.
  • The transfer() method allows producers to send elements directly to consumers.

Example: This example, demonstrates how to add elements to a LinkedTransferQueue and then retrieve and print them using poll() until the queue is empty.

Java
// Java Program to demonstrate the 
// working of LinkedTransferQueue
import java.util.concurrent.*;

public class Geeks {
    public static void main(String[] args) {
        
        // Create a LinkedTransferQueue
        LinkedTransferQueue<String> q = new LinkedTransferQueue<>();

        // Add some elements to the queue
        q.add("1");
        q.add("2");
        q.add("3");

        // Print the elements of the queue
        System.out.println("LinkedTransferQueue is: ");
        while (!q.isEmpty()) {
            System.out.print(q.poll() + " ");
        }
    }
}

Output
LinkedTransferQueue is: 
1 2 3 


LinkedTransferQueue Hierarchy