dimanche 1 mars 2015

Should I implement the consumer/producer pattern in my java video app, and if yes, how?

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:



  1. the main thread

  2. the producer thread

  3. the consumer thread


Is there an advantage in doing that compared to a 2 thread implementation?



  1. main and producer thread

  2. consumer thread


And is that the right way to handle real-time data with a database?


PS: the above question was asked here, but I was told it would be better to ask on SE.programmers instead.


Aucun commentaire:

Enregistrer un commentaire