1.

What Is Transferqueue In Java?

Answer»

TransferQueue interface, ADDED in Java 7, extends BlockingQueue interface. The extra functionality provided by TransferQueue interface is that it provides blocking method which will WAIT until other thread receives your element.

That's how it differs from BlockingQueue where you can only put element into queue or retrieve element from queue and block if queue is FULL (while you are putting elements) or block if queue is empty (while you are retrieving elements).

TransferQueue has a blocking method transfer(E e) which will ENSURE that the element is transferred to the consumer, it will wait if required to do so.

TransferQueue interface, added in Java 7, extends BlockingQueue interface. The extra functionality provided by TransferQueue interface is that it provides blocking method which will wait until other thread receives your element.

That's how it differs from BlockingQueue where you can only put element into queue or retrieve element from queue and block if queue is full (while you are putting elements) or block if queue is empty (while you are retrieving elements).

TransferQueue has a blocking method transfer(E e) which will ensure that the element is transferred to the consumer, it will wait if required to do so.



Discussion

No Comment Found