import _thread import time import sys sys.setswitchinterval(1000) def countdown(n,lck): while n > 0: n = n - 1 lck.release() # Signal termination lck_1 = _thread.allocate_lock() lck_2 = _thread.allocate_lock() lck_1.acquire() lck_2.acquire() start = time.time() _thread.start_new_thread(countdown,(5000000,lck_1)) _thread.start_new_thread(countdown,(5000000,lck_2)) lck_1.acquire() # Wait for termination lck_2.acquire() end = time.time() k = end - start print(k)