Demo Program - Mutex Locks in Python

#!/usr/bin/python3
# ===================================================================
# from: stackoverflow.com/questions/3310049/
#                         proper-use-of-mutex-in-python
# ===================================================================

from threading import Thread, Lock
import time

mutex = Lock()

def processData(data):
    mutex.acquire()
    try:
        print(f'do some stuff ({data})')
    finally:
        mutex.release()

i = 0
while(True):

    i += 1
    if i > 10:
        break

    some_data = f'me={i}'

    t = Thread(target=processData, args=(some_data,))
    t.start()
    ####t.join()
    time.sleep(1)