2025-09-10:仓库迁移
This commit is contained in:
20
12.并发/1.启动和停止线程.py
Normal file
20
12.并发/1.启动和停止线程.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import time
|
||||
|
||||
def countdown(n):
|
||||
while n > 0:
|
||||
print("T-minus", n)
|
||||
n -= 1
|
||||
time.sleep(5)
|
||||
|
||||
def countdown2(n):
|
||||
while n > 0:
|
||||
print("T-minus", n)
|
||||
n -= 1
|
||||
time.sleep(6)
|
||||
|
||||
from threading import Thread
|
||||
|
||||
t = Thread(target=countdown, args=(10, ))
|
||||
t.start()
|
||||
t2 = Thread(target=countdown2, args=(10, ))
|
||||
t2.start()
|
Reference in New Issue
Block a user