The difference between the face questions python python multi-threaded and multi-process

Reprinted from the article: http://www.pythonheidong.com/blog/article/5/

Multithreading can share global variables, multiple processes can not

Multi-threading, the same number for all sub-thread process, multi-process, different process ID of the child process


Threads share memory space; the process is independent of memory

Direct communication between threads of the same process; two processes want to communicate, must be achieved through an intermediate proxy

Create a new thread is simple; create a new process needs to be a clone of the parent process

A thread can control and operate the same process in the other thread; but the process can only operate child process


We should try to avoid multiple processes to share resources. Multiple processes to share resources among competing processes is bound to bring each other. And this competition will cause race condition, our results may be affected by the uncertainty of the competition. But if necessary, we can still do so via shared memory and Manager objects.

Reprinted from the article: http://www.pythonheidong.com/blog/article/5/

Guess you like

Origin www.cnblogs.com/xiongbatianxiaskjdskjdksjdskdtuti/p/11356120.html