线程_ThreadLocal

import threading
# 创建ThreadLocal对象
house = threading.local()

def process_paper():
    user = house.user
    print("%s是房子的主人,in %s"%(user,threading.current_thread().name))

def process_thread(user):
    house.user = user
    process_paper()

t1 = threading.Thread(target=process_thread,args=('Xiaoming',),name='佳木斯')
t2 = threading.Thread(target=process_thread,args=('Hany',),name='哈尔滨')
t1.start()
t1.join()
t2.start()
t2.join()

2020-05-07

上一篇:系统测试过程各阶段的输入、输出是什么?


下一篇:32 Spring Cloud Zuul路由配置详解