python threading 自定义多线程-固定线程执行任务

2018-08-08  本文已影响0人  数据小新手

## 你好

```

from threadingimport Thread 

import threading

def test(a,b):

print('test')

print(a+b,a,b,threading.current_thread())

class myThread (threading.Thread):

def __init__(self, name):

threading.Thread.__init__(self)

self.name = name

def run(self,a,b):

test(a,b)

print ("开始线程:" +self.name,threading.currentThread())

def main():

t=myThread('one')

for in range(5):

a=i+1

        b=i+2

        t.run(a,b)

main()

```

上一篇下一篇

猜你喜欢

热点阅读