import threading
lock = threading.Lock () # create a thread lock: mutex
NUM = 100
DEF RUN (name):
lock.acquire () # set the lock
global num # Set the global variable NUM
NUM NUM-1 =
Print ( "threads" num, "the implementation of the current value of num:", num)
lock.release () # release lock
#for loop to create a thread 100
for I in Range (100):
T = of the threading.Thread (target = RUN, args = (I +. 1,))
t.start ()