The
java.util.concurrent.LinkedTransferQueue.take() method is an in-built function in Java which retrieves and remove the first element of the queue. This method also waits (if necessary) until an element becomes available.
Syntax:
LinkedTransferQueue.take()
Parameters: The function does not accept any parameter.
Return Value: The function returns the first element of the queue.
Exceptions: The function throws
InterruptedException if interrupted while waiting.
Below programs illustrate the java.util.concurrent.LinkedTransferQueue.take() :
Program 1:
Output:
Elements are :
Alex
Bob
Chuck
Drake
Eric
Queue Size: 0
Program 2: