码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2021-01-13 10:50:50      阅读:0      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!