Process common attributes

from multiprocessing Import Process
 Import Time 

DEF FUNC ():
     for I in Range (500 ): 
        the time.sleep ( 0.01 )
         Print ( ' son here ' ) 

IF  the __name__ == ' __main__ ' : 
    P = Process (target = FUNC) 
    P .start () 
    p.join () # is to make the main process waits for the child process executed. Phenomenon: the main process to execute the sentence, the main process blocked live, wait for the child to perform 
    # the time.sleep (1) 
    for i in the Range (100 ):
        the time.sleep ( 0.01 )
         Print ( ' father here ' ) 

# open a normal child, the parent process will wait for the end of the child, the parent is the program until the end of 
# p.join () # is to wait for the main process child process executed. Phenomenon: the main process to execute the sentence, the main process blocked live, waiting for child process 
# how the relationship between parent and child processes become synchronous or asynchronous? 
# Parent process join, will become synchronized, does not perform join, the parent and child processes is asynchronous relationship 
# the Join must be placed in start () behind

 

Guess you like

Origin www.cnblogs.com/god-for-speed/p/11719067.html