hi all:
these days I'm learning to use multiprocess and multithread. I've a question that when a child process is better than create threads. And under what condition in your code, you'll use multithread other than multiprocess?
thank !
Printable View
hi all:
these days I'm learning to use multiprocess and multithread. I've a question that when a child process is better than create threads. And under what condition in your code, you'll use multithread other than multiprocess?
thank !
For small tasks, and tasks where you must share memory and such, threads are probably best.
Threads are better because they consume a little bit resource than process.
Use multiprocessing when your application depend on someone's application that not open-source or a complex one (so you can't port it to your application to become a thread) or a-non-thread-safe one.
Process theoretically have also the advantage that if one process fails, the rest will remain. In some cases you would want that. Theoretically, because maybe some OS will kill everything create from the father process.