线程通信-全局变量-标准库threading

2021-03-07 14:31

阅读:639

标签:pre   imp   sleep   rom   color   start   线程通信   int   join()   

 

from threading import Thread 
from time import sleep 


a = 1

def foo():
    global a
    a = 1000

def bar():
    sleep(1)
    print("a = ",a)

t1 = Thread(target = foo)
t2 = Thread(target = bar)

t1.start()
t2.start()

t1.join()
t2.join()

 

线程通信-全局变量-标准库threading

标签:pre   imp   sleep   rom   color   start   线程通信   int   join()   

原文地址:https://www.cnblogs.com/longyuu/p/14261712.html


评论


亲,登录后才可以留言!