I built a small video frame analysis app with desktop Java 8. On each frame, I extract data (5 doubles now, but could expand to a 1920x1080x3 OpenCV Mat
in the future). I would like to store this data into a database (Java DB, for example) to perform some time-series analysis, and periodically return the results to the user.
I am worried about hard-drive access times if I write to the database and run the app on a single thread, and the best solution that occured to me would be to implement the producer/consumer pattern with multithreading. The examples I found all implement 3 threads:
- the main thread
- the producer thread
- the consumer thread
Is there an advantage in doing that compared to a 2 thread implementation?
- main and producer thread
- consumer thread
And is that the right way to handle real-time data with a database?