[concurrency-interest] Method on LinkedBlockingQueue throwsIllegalStateException

David Holmes dcholmes at optusnet.com.au
Tue Apr 17 18:54:56 EDT 2007

The inherited methods from Collection et al were not intended for
multi-threaded use. Hence the BlockingQueue interface was defined to provide
the desirable semantics for multi-threaded use. It was considered very
important that concurrent collections also support the legacy Collection

If want blocking behaviour when encountering full/empty conditions then use
the methods from BlockingQueue in place of similar methods from Collection.

David Holmes

> -----Original Message-----
> From: concurrency-interest-bounces at cs.oswego.edu
> [mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of Szabolcs
> Ferenczi
> Sent: Wednesday, 18 April 2007 8:19 AM
> To: Joe Bowbeer
> Cc: concurrency-interest
> Subject: Re: [concurrency-interest] Method on LinkedBlockingQueue
> throwsIllegalStateException
> On 17/04/07, Joe Bowbeer <joe.bowbeer at gmail.com> wrote:
> > Look at the documentation for Queue.
> >
> > In particular, the distinction between 'add' and 'offer':
> >
> > http://java.sun.com/javase/6/docs/api/java/util/Queue.html
> Well, I did have a look at it. That is why I made my point. What is
> your point? Did you think about it?
> Your reference is to an interface definition for a sequential data
> structure. I called your attention, well it seems you are not
> listening, that there is a big difference between operations on a
> sequential data structure and a shared data structure. By sequential
> data structure I mean one that is designed to be used in a single
> threaded environment.
> I am talking about method `add' and not about method `offer.' Do you
> think it is a correct behavior throwing an exception if a shared data
> structure is not in the expected state?
> Besides, method `offer' also smells in multi-threaded environment. But
> it at least returns false in case the state is not as expected.
> Best Regards,
> Szabolcs
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at altair.cs.oswego.edu
> http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest

More information about the Concurrency-interest mailing list