Unbounded queues. Using an unbounded queue (for example a
LinkedBlockingQueue without a predefined capacity) will cause new
tasks to wait in the queue when all corePoolSize threads are busy.
Thus, no more than corePoolSize threads will ever be created. (And the
value of the maximumPoolSize therefore doesn't have any effect.)

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

And this written for ArrayBlockingQueue:

Bounded queues. A bounded queue (for example, an ArrayBlockingQueue)
helps prevent resource exhaustion when used with finite
maximumPoolSizes, but can be more difficult to tune and control. Queue
sizes and maximum pool sizes may be traded off for each other: Using
large queues and small pools minimizes CPU usage, OS resources, and
context-switching overhead, but can lead to artificially low
throughput. If tasks frequently block (for example if they are I/O
bound), a system may be able to schedule time for more threads than
you otherwise allow. Use of small queues generally requires larger
pool sizes, which keeps CPUs busier but may encounter unacceptable
scheduling overhead, which also decreases throughput.

4 Answers
4

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.

A bounded blocking queue backed by an array. This queue orders elements FIFO (first-in-first-out). The head of the queue is that element that has been on the queue the longest time. The tail of the queue is that element that has been on the queue the shortest time. New elements are inserted at the tail of the queue, and the queue retrieval operations obtain elements at the head of the queue.

If you notice all the constructors of ArrayBlockingQueue take a capacity because this class was designed to be bounded. This choice was made because if you want a concurrent queue, you probably don't want the overhead that comes with resizing an ArrayList. Hence, if you want an unbounded queue LinkedBlockingQueue is a better option since it does not involve this overhead.