From threading import thread
from time import sleep
counter = 0
def increase(by):
    global counter
    local_counter = counter
    local_counter += by
    sleep(0.1)
    counter = local_counter
    print(f’counter={counter}’)

# create threads
t1 = thread(target=increase, args=(10, ))
t2 = thread(target=increase, args=(20, ))

# start the threads
t1. Start()
t2. Start()

# wait for the threads to complete
t1. Join()
t2. Join()
print(f’the final counter is {counter}’)