Why the ArrayBlockingQueue is called a bounded queue while a LinkedBlockingQueue is called an unbounded blocking queue?

Why do you think that an ArrayBlockingQueue can grow without bounds? From its own documentation:

This is a classic "bounded buffer", in which a fixed-sized array holds elements inserted by producers and extracted by consumers. Once created, the capacity cannot be increased. Attempts to put an element into a full queue will result in the operation blocking; attempts to take an element from an empty queue will similarly block.

In other words, once it gets full, it's full - it doesn't grow.

Are you getting confused with an ArrayList by any chance - which is also backed by an array, but which expands this as required?

So does the Unbounded Queue property changes when the LinkedBlockingQueue has a defined capacity ?

Yes, hence why it's described as "optionally-bounded" in its Javadocs. Furthermore, the docs state that (emphasis mine):

The optional capacity bound constructor argument serves as a way to prevent excessive queue expansion. The capacity, if unspecified, is equal to Integer.MAX_VALUE. Linked nodes are dynamically created upon each insertion unless this would bring the queue above capacity.


The javadoc for LinkedBlockingQueue says:

An optionally-bounded blocking queue based on linked nodes.[...]

The optional capacity bound constructor argument serves as a way to prevent excessive queue expansion. The capacity, if unspecified, is equal to Integer.MAX_VALUE.

The javadoc of ArrayBlockingQueue says:

A bounded blocking queue backed by an array.[...]

This is a classic "bounded buffer", in which a fixed-sized array holds elements inserted by producers and extracted by consumers. Once created, the capacity cannot be increased

So, a LinkedBlockingQueue can be bounded or unbounded, whereas an ArrayBlockingQueue is always bounded.


As far as I know both the linked list and array can grow without bounds or am I wrong

A linked list as an unlimited size. An array has fixed size. An ArrayList wraps an array and replaces it when it needs a bigger one.

So does the Unbounded Queue property changes when the LinkedBlockingQueue has a defined capacity

When LinkedBlockingQueue has a maximum capacity, it is bounded but it not used this way by default.