# RunFunctionThread.py from Dr. Karen Works # example of running a function in another thread from time import sleep from threading import Thread # a function that blocks for a moment def task(): # block for a moment sleep(1) # display a message print('task thread running for 1 second') sleep(10) print('task thread running for 3 second') # create a thread thread = Thread(target=task, daemon = True) # run the thread thread.start() # wait for the thread to finish print('Main thread after task thread starts...')