
# https://www.globalsino.com/ICs/page4853.html
# With threading


from time import sleep, perf_counter
from threading import Thread


def new_task():
    print('\nStarting a new task')
    sleep(1)
    print('\nThe new task is done')


start_time = perf_counter()

new_task_1 = Thread(target=new_task)
new_task_2 = Thread(target=new_task)

new_task_1.start()
new_task_2.start()

# Wait for the threads to complete
new_task_1.join()
new_task_2.join()

end_time = perf_counter()

print(f'It took {end_time- start_time: 0.2f} second(s) to complete.')
