多线程——进行自定义运算
1 import threading 2 def a(aa): 3 global aa1 4 aa1-=aa 5 print(aa1,aa,threading.current_thread().name) 6 7 aa1=100 #定义起始数值 8 def threadd(): 9 global aa1 10 print(threading.current_thread().name) 11 for i in range(3): 12 13 bb=[] 14 for ii in range(2): 15 a1=int(input()) #输入自已的数值 16 print(a1,type(a1)) 17 t =threading.Thread(target=a,args=(a1,)) 18 t.start() 19 bb.append(t) 20 for t1 in bb: 21 t1.join() 22 #time.sleep() 23 24 threadd()
不是所有的成功都是坐享其成,联系作者v(13147256756)