I will be getting a JSON string every .01 seconds or even faster and I have to insert it in some collection so that I can later loop through every row and do some processing and delete that row after that. The process of insertion keeps on going. I am a bit confused as whether to use ArrayList
or Queue
.
So basically I would insert the first message then second and then ... and simultaneously another process would read the first inserted value for processing and deleting that record followed by second inserted value. Please advise which one would be fastest and takes less storage? Or any other collection would best suit my requirement?
Edit: I have two methods -
GetMessages() - which keeps on getting/adding messages in queue (here the messages are received from only one source which keeps on sending messages and does not stop till we manually stop the process)
ProcessMessages() - which will read the queue records and after processing delete them from the queue