Multithreading data

Find the nearest available sample data by way of keyword matching, due to the relatively slow speed, so trying to use multi-threading up, improve my speed. Now familiar with the basic operations:

"" " 
    Function: Sample multithreading 
    the Author: DYX 
    the DateTime: 20,191,021 
" "" 
from Threading Import the Thread
 Import Time 


DEF main (name = " Python " ):
     for I in Range (. 5 ):
         Print ( ' Hi ' , name ) 
        the time.sleep ( 1 ) 

# create a thread 1 does not specify the parameters 
thread_01 = the thread (target = main)
 # start a thread 1 
thread_01.start () 

thread_02 = the thread (= main target, args = ( "deng",))
thread_02.start()


if __name__ == '__main__':
    t1 = time.time()
    main()
    t2 = time.time()
    print('单机耗时:{}'.format(t2-t1))

 

Guess you like

Origin www.cnblogs.com/demo-deng/p/11711823.html