The import multiprocessing
The import threading
The import OS
Def CMD () :
OS. The system (' netstat)
Def test () :
Print (' 00000000000 ')
If __name__=="__main__ ':
# thread
Threading. Thread (target=CMD ()). The start ()
Threading. Thread (target=test ()). The start ()
# process
# multiprocessing. Process (target=CMD ()). The start ()
# multiprocessing. Process (target=test ()). The start ()
Is meant to two functions performed at the same time, but actually found whether the thread or process, will be stuck because the first function, and to end the first function to perform the second function, to solve this kind of circumstance, don't change under the condition of a subroutine, to perform two functions at the same time how to solve
CodePudding user response:

If __name__=="__main__ ':
# thread
Threading. Thread (target=CMD). The start ()
Threading. Thread (target=test). The start ()
They found that python science writing is maddening, when call subroutine remove the () behind the called function, can realize the parallel, I depend!!!!!!!!!!!
CodePudding user response:

For example, in pyqt5 associated button event response function also is such,
CodePudding user response:
Target=CMD ()==& gt; CMD to remove test brackets () the sameCodePudding user response: