1from threading import Thread, Lock
2
3mutex = Lock()
4
5def processData(data):
6 mutex.acquire()
7 try:
8 print('Do some stuff')
9 finally:
10 mutex.release()
11
12while True:
13 t = Thread(target = processData, args = (some_data,))
14 t.start()