python8.1 multithreading

import threading
import time

runl DEF (name, Sex):
Print (name, Sex, "execution thread. 1")
the time.sleep (. 3)
DEF RUN2 (name, Sex):
Print (name, Sex, "execution thread 2")
the time.sleep ( 3)

# Runtime itself is a main thread t1, t2 are the two child threads.
Run # main thread does not wait for the child threads!
# Create a thread
t1 = threading.Thread (target = run1, args = ( " Joe Smith", "male"))
T2 = threading.Thread (target = RUN2, args = ( "John Doe", "female") )

# Start a thread
t1.start ()
t2.start ()
# Set the child thread is finished, the main thread execution
t1.join ()
t2.join ()
Print ( "End")

 

Guess you like

Origin www.cnblogs.com/lma0702/p/11119930.html