lundi 9 mars 2015

2 threads vs 2 processes (design/performance/isolation)

I need to decide whether to use 2 threads, or 2 processes (in either case, both will connect to the same database).


2 threads would be able to share the same memory, and there's no need for them to write to that shared memory: even though they are doing different jobs, they will only read from the memory and not change it.


So my questions are:




  1. Might I have a problem when 2 different programs insert or extract values from the database if they both run at the same time? (I know that I can synchronize my threads)




  2. Which will have better performance? Which will be faster?




  3. With 2 threads, it's harder to debug the program than with 2 processes. Which design will be more correct and easier for me to work with?




If i work with 2 processes, I will need to connect to the database twice; whereas threads could share the same memory.


I am using Java and MySQL.


Aucun commentaire:

Enregistrer un commentaire