Thread: Figure 11.2

来源:互联网 发布:java获取当前系统时间 编辑:程序博客网 时间:2024/06/05 00:09
"""APUE Figure 11.2 Printing. thread IDs."""from threading import Thread, currentThread, RLockimport timelock = 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)


原创粉丝点击