Writing Reentrant and Thread-Safe Code 编写可重入和线程安全的代码 (http://www.ualberta.ca/dept/chemeng/AIX-43/share/man/info/C/a_doc_lib/aixprggd/genprogc/writing_reentrant_thread_safe_code.htm) In single-threaded processes there is only one flow of control. The…
不多解释,预防普通锁不正规的获取与释放 #!/usr/bin/env python # -*- coding: utf-8 -*- import threading import time class MyThread(threading.Thread): def run(self): global num time.sleep(1) if mutex.acquire(1): num += 1 msg = self.name + ' set num to ' + str(num) print m…