Currently I'm reading Collections in java. As I read, LinkedTransferQueue
is superset of LinkedBlockingQueue
whose put(E e)
method inserts and object and returns void and if need, will block until space in the queue becomes available. But I don't see any constructor of LinkedTransferQueue
which accepts capacity to bound it by size.
So how and when an invocation of put
method on a LinkedBlockingQueue will block by considering it full as we did not specify a bounded size for it anywhere.
I came across following lines of code which i did not get.
TransferQueue<Integer> tq = new LinkedTransferQueue<>(); // not bounded.
tq.put(2); // blocks if bounded and full
what is the meaning of comment at line-2.
Thanks.