Search code examples
javacollectionsjava.util.concurrent

Multiple threads writing in a collection concurrently


I am having a scenario, in which lot of threads needs to share a collections and the threads keep on writing in the collection, comparatively writes are many and reads are very less, I am not sure ArrayBlockQueue is a correct collection to be used. Should I implement my own collection or do I get anything out of the Box in Java?

Please help.


Solution

  • I suggest you read the code for ArrayBlockingQueue and Disruptor first. If you think you can do it much better, you might write your own, but it is highly likely that writing your own won't be as performant, or well tested.