I read the log files, but not all lines want to be processed immediately. I use a queue / buffer to store strings while they are waiting for processing.
This queue is regularly scanned for certain lines - when they are found, they are removed from the queue (they can be anywhere in it). When there is no specific line to be found, the lines are taken out of the queue one by one for processing.
Therefore, the queue requires the following:
- The ability to resize (or create such an impression)
- Items removed from anywhere
- Elements added (will always be at the end of the queue)
- Scan fast
- Depending on performance, a pointer to where it was on the last scan.
I originally wrote the code when I had little Java or API experience, and just used ArrayList because I knew that it would work (not necessarily because this is the best option).
Currently, its performance is getting worse and more and more magazines need to be processed - so which collection would you recommend to use in this situation? There is always the opportunity to write too.
thank
source
share