python_multithread

1.首先是一个问题,有知道的请求讨论



2.关于join的问题(join:不间断join中的线程)

join ( timeout=None )

Wait until the thread terminates. This blocks the calling thread until the thread whose join() method is called terminates – either normally or through an unhandled exception – or until the optional timeout occurs.

大意是:等待直到线程终止。此功能可以阻止被调线程,直到某个加入到join中的线程出错,或者执行完。

thread1 = threading.Thread(target = job, name = 'T1') ###此处的()不可以有(查了一段时间的问题)
     thread1.start()
     ####thread1.join()
     print('main end')

 

3.被多线程回调的函数不能有返回值。此时可以通过queue来进行

    

class multiprocessing. Queue ( [ maxsize ] )

Returns a process shared queue implemented using a pipe and a few locks/semaphores. When a process first puts an item on the queue a feeder thread is started which transfers objects from a buffer into the pipe.

应该用的是这个(多线程专用的)

4.关于lock的东西

不可以在子函数中定义全局变量,即使是main函数都不行

有时候会出问题。例如,行对其的问题

其余参考网上找的一篇,写的还不哦


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值