Usecase :
its a producer consumer pattern where order (FIFO) is to be maintained. As of now there is single producer and a single consumer to process data in sequential manner to maintain order, but in future ( due to removal of some business constraint ) this requirement of maintaining order will no longer be there. At that time, we will be able create multiple producers and consumer working on same queue.
I can see two solutions :
I can implement data pipes between producer and consumer using a) ArrayBlockingQueue b) Can use Exchangers and use two ArrayListsas underlying data structure
Question :
what are the relative Pros and Cons of these two implementation with respect to concurrancy ?
My thought :
I think Exchangers would be better in terms of concurrency as threads are reading and writing on different ArrayLists but the down side is that producers may have to wait till arraylist of consumer is full and can be exchanged.
thanks in advance for sharing your view.