I have a scenario where I have a class that’s a listener to a server. When I am notified I keep adding a string of values to an ArrayList. I now have threads that read from this ArrayList.
This ArrayList has the potential of becoming very large. I’m thinking of spawning a thread that checks every 10 mins if the max size has been reached and deletes a few lines that were added.
I was wondering what is the best way to achieve this?
Should I be using another DS?
You might want to consider using a
LinkedList.*
ArrayList.addruns in O(n) worst case if the array needs to be resized.