import threading
def task(task_number):
print(f"Task
{task_number} in thread {threading.current_thread().name}")
def main():
tasks = 4
threads = []
for i in range(tasks):
thread =
threading.Thread(target=task, args=(i+1,))
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
print("All tasks are
completed")
if __name__ == "__main__":
main()
No comments:
Post a Comment