#多线程---全局变量----共享(线程并不像进程那样创建一个进程就Copy一次代码) from threading import Thread import time,random g_num = 100 def work1(): global g_num for i in range(3): g_num += 1
Python3-多线程共享全局变量
最新推荐文章于 2024-07-29 02:30:04 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)
#多线程---全局变量----共享(线程并不像进程那样创建一个进程就Copy一次代码) from threading import Thread import time,random g_num = 100 def work1(): global g_num for i in range(3): g_num += 1