python8.2 thread lock

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 ()

Guess you like

Origin www.cnblogs.com/lma0702/p/11119935.html