I have this situation:
Web application with 200 consistent requests (Threads) need to write something to the local file system. I have one class to which all threads place their calls, and this class internally stores messages in a single array (Vector or ArrayList), which then, in turn, will be written to the file system.
The idea is to return from the ASAP call flow so that the thread can do this work as quickly as possible, what the thread wanted to write to the log can be written to the file system later, this is not so important.
So, this class, in turn, removes the first element from this list and writes it to the file system, while in real time there are 10 or 20 threads that add new logs at the end of this list.
I would like to use an ArrayList since it is not synchronized, and so the calls to the threads will be less, the question is
Am I at risk of facing / data loss? Is it better to use a Vector because it is thread safe? Is it slower to use Vector?
source
share