"""
APUE Figure 11.2 Printing. thread IDs.
"""
from threading import Thread, currentThread, RLock
import time
lock = RLock()
def printThreadId(ss):
lock.acquire()
print ss, currentThread().name
lock.release()
def f():
printThreadId("new threads: ")
def main():
t = Thread(target=f)
t.start()
printThreadId("main thread: ")
main()
time.sleep(1)
exit(0)
Thread: Figure 11.2
最新推荐文章于 2023-07-07 20:29:39 发布