import threading
import time

# 子執行緒的工作函數
def job(num):
  print("Thread", num)
  time.sleep(1)

# 建立 5 個子執行緒
threads = []
for i in range(5):
  threads.append(threading.Thread(target = job, args = (i,)))
  threads[i].start()

# 主執行緒繼續執行自己的工作
# ...

# 等待所有子執行緒結束
for i in range(5):
  threads[i].join()

print("Done.")
88148e4c12cbf45b6eed87de5fe70285ab58f3e5
<mask token>


def job(num):
    print('Thread', num)
    time.sleep(1)


<mask token>

<mask token>


def job(num):
    print('Thread', num)
    time.sleep(1)


<mask token>
for i in range(5):
    threads.append(threading.Thread(target=job, args=(i,)))
    threads[i].start()
for i in range(5):
    threads[i].join()
print('Done.')

<mask token>


def job(num):
    print('Thread', num)
    time.sleep(1)


threads = []
for i in range(5):
    threads.append(threading.Thread(target=job, args=(i,)))
    threads[i].start()
for i in range(5):
    threads[i].join()
print('Done.')

import threading
import time


def job(num):
    print('Thread', num)
    time.sleep(1)


threads = []
for i in range(5):
    threads.append(threading.Thread(target=job, args=(i,)))
    threads[i].start()
for i in range(5):
    threads[i].join()
print('Done.')

import threading
import time

# 子執行緒的工作函數
def job(num):
  print("Thread", num)
  time.sleep(1)

# 建立 5 個子執行緒
threads = []
for i in range(5):
  threads.append(threading.Thread(target = job, args = (i,)))
  threads[i].start()

# 主執行緒繼續執行自己的工作
# ...

# 等待所有子執行緒結束
for i in range(5):
  threads[i].join()

print("Done.")