首页 > 编程语言 > 详细

线程_多线程_列表当做实参传递到线程中

时间:2020-05-07 22:22:24      阅读:70      评论:0      收藏:0      [点我收藏+]
from threading import Thread


def work1(nums):
    nums.append(a)
    print(---在work1中---,nums)

def work2(nums):
    print("-----在work2中----,",nums)

if __name__ == __main__:
    g_nums = [1,2,3]
    t1 = Thread(target=work1,args=(g_nums,))
    # target函数,args参数
    t1.start()

    t2 = Thread(target=work2,args=(g_nums,))
    t2.start()

2020-05-07

from threading import Thread


def work1(nums):
nums.append(‘a‘)
print(‘---work1---‘,nums)

def work2(nums):
print("-----work2----,",nums)

if __name__ == ‘__main__‘:
g_nums = [1,2,3]
t1 = Thread(target=work1,args=(g_nums,))
# target函数,args参数
t1.start()


t2 = Thread(target=work2,args=(g_nums,))
t2.start()

线程_多线程_列表当做实参传递到线程中

原文:https://www.cnblogs.com/hany-postq473111315/p/12845630.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!