Home > other >  Help: multi-threading threads stuck can't continue to the next
Help: multi-threading threads stuck can't continue to the next

Time:12-02

 
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:

yes, function as a parameter of time can't add parentheses,

For example, in pyqt5 associated button event response function also is such,

CodePudding user response:

Target=CMD ()==& gt; CMD to remove test brackets () the same

CodePudding user response:

refer to the second floor teamlet response:
yes, function as a parameter of time can't add parentheses,

For example, in pyqt5 associated button event response function also is such,


This reminds me, thanks to the moderators

CodePudding user response:

The
reference 3 floor chuifengde response:
target=CMD ()==& gt; CMD to remove test brackets () the same

Wow, great spirit, this edition piece of scoring more than 5000, a great god!!!!!!

CodePudding user response:

Oh oh, posts the old brush less than the latest reply, didn't see it
  • Related