Your choices basically revolve around what you want, when for some reason a backup of the queue and how much memory you want to use.
If itโs convenient for you to stop the main process until the log stream clears part of the queue, then ArrayBlockingQueue will be fine, because it (and fixed in size) will not consume your memory under heavy load.
If you are comfortable ignoring memory issues when backing up logs (you may be sure that the logging flow will always be supported), then LinkedBlockingQueue might be better, as it is slightly more optimal and unlimited. It can also be given a size limit, but this is optional.
If you use any of them, you do not need to add synchronization logic, as they do everything themselves.
Where can I store a synchronized list of objects to be processed between two threads (in a processing thread or in the main thread?)
Or, you usually create it in your main thread and pass it to the logging stream and the processing stream, because both of them will share it.
What is the best practice for adding / removing items from a list? via a synchronized function or directly to a List object?
BlockingQueue provides a rich API for thread safe adding and removing elements.
What are my options for List objects when creating a job queue?
See above.
source share