[concurrency-interest] Method on LinkedBlockingQueue throws IllegalStateException

Joe Bowbeer joe.bowbeer at gmail.com
Tue Apr 17 17:34:58 EDT 2007

Look at the documentation for Queue.

In particular, the distinction between 'add' and 'offer':


On 4/17/07, Szabolcs Ferenczi <szabolcs.ferenczi at gmail.com> wrote:
> There is a method defined on LBQ (well already on AbstractQueue)
> that throws IllegalStateException. The LinkedBlockingQueue.add method
> throws an IllegalStateException when the queue is at the max capacity
> (full) at the time the method is called. It is strange, isn't it? But
> it is true.
> I believe an operation on a queue being full is not illegal in a multi-threaded
> environment. It just happens sometimes at non deterministic moments.
> I think, throwing the exception might be justified on a data structure, which is
> designed to be used in a single threaded environment but it is a
> completely mistaken behavior on a shared data structure. I hope the
> reason why is obvious to anyone who works with multiple threads.
>  I think this method and related ones such as the method remove (throws
> NoSuchElementException) should be fixed in forthcoming releases,
> if methods like these are needed at all.
> Any comment?
> Best Regards,
> Szabolcs

More information about the Concurrency-interest mailing list