简体   繁体   中英

LinkedBlockingQueue - unbounded - put blocking?

I have 2 simple questions here. I have a LinkedBlockingQueue which I create simply as

new LinkedBlockingQueue()

So I think this guarantees that is unbounded, is that right?
If indeed so, is it right to say that the method put can never block when called on this queue instance?

The Java docs specify that a no-arg constructor invocation will result in a capacity of Integer.MAX_VALUE , which is large but not actually infinite, so the queue is bounded (but for practical purposes, it might as well not be).

The put method will block only if space needs to become available, meaning it will block if the queue already has a number of elements equal to capacity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM