How convenient is multithreading compared to multiprocessing?
There are basically two ways in which one can make use of a modern CPU with multiple cores for computationally intensive work.
- Using multiple threads within one program (multithreading).
- Using multiple (single-threaded) programs that communicate (multiprocessing).
In the first case, all data is implicitly shared. In the second case, data must be explicitly shared or communicated.
The first option is often said to be more convenient. I would like to make the case that this usually makes the task more difficult, because of the need to manage all shared data.