python-多線程-共享變量問題

import threading sum = 0 loopSum = 1000000 lock = threading.Lock() def Add(): global sum, loopSum for i in range(1,loopSum): lock.acquire() sum += 1 lock.release()
相關文章
相關標籤/搜索