tags:

views:

1496

answers:

2

I think I shall reframe my question from

Where should you use BlockingQueue Implementations instead of Simple Queue Implementations ?

to

What are the advantages/disadvantages of BlockingQueue over Queue implementations taking into consideration aspects like speed,concurrency or other properties which vary e.g. time to access last element.

I have used both kind of Queues. I know that Blocking Queue is normally used in concurrent application. I was writing simple ByteBuffer pool where I needed some placeholder for ByteBuffer objects. I needed fastest , thread safe queue implementation. Even there are List implementations like ArrayList which has constant access time for elements.

Can anyone discuss about pros and cons of BlockingQueue vs Queue vs List implementations?

Currently I have used ArrayList to hold these ByteBuffer objects.

Which data structure shall I use to hold these objects?

A: 

You would see BlockingQueue in multi-threaded situations. For example you need pass in a BlockingQueue as a parameter to create ThreadPoolExecutor if you want to create one using constructor. Depending on the type of queue you pass in the executor could act differently.

eed3si9n
+5  A: 
erickson
Thanks Erickson for such a nice explanation.It has solved my problem.
Vaibhav Kamble