以多线程为例写个互斥锁 from threading import Thread ,Lockimport timemutex = Lock() n = 100 def task(): global n with mutex: temp = n time.sleep(0.1) n= temp-1 if __name__ == '__main__': t_l = [] start_time = time.time() for i in range(100): t = Thread(target=ta