徹底搞懂 python進(jìn)程和線程

這兩種寫法有區(qū)別沒有呀
loop=1000000000
x=0
def sum_3( count):
global x
for n in range (count):
x+=n
print ( f"sum_2:{x}" )
y=0
def sum_5( ):
global y
for n in range (1,1000000000):
y+=n
print ( f"sum_2:{y}" )
t1 = threading.Thread(target=sum_3,args = (loop,))
t1.start()
t2 = threading.Thread(target=sum_5)
t2.start()
print(x)
print(y)
標(biāo)簽: