[concurrency-interest] ArrayBlockingQueue and addAll()

Doug Lea dl at cs.oswego.edu
Thu Oct 19 14:01:22 EDT 2006


Kasper Nielsen wrote:
> Hi,
> 
> Any reason for not letting ArrayBlockingQueue.addAll() use a more 
> efficient implementation then the one inherited from AbstractCollection?
> 

It is mainly because there's not a huge possibility for improvement.
Suppose for example a queue with capacity 100 gets calls from two different
threads to addAll with 200 elements each. At best you could put in the
first 100 for the first one, and let the others contend one-by-one as
consumers remove elements. This and other small improvements aren't
usually enough faster that letting all of them contend one-by-one
to deserve explicit coding. Although people who frequently hit cases
where it would be enough faster to bother, might feel differently.
So it is a good suggestion for a potential small performance improvement,
that we ought to take up someday. Thanks!

-Doug



More information about the Concurrency-interest mailing list