标签:targe oat http div 打印 star float 调用 rom
它会阻止线程。如果查看Python源代码中的Modules / timemodule.c,您会看到在调用中floatsleep(),睡眠操作的实质部分包含在Py_BEGIN_ALLOW_THREADS和Py_END_ALLOW_THREADS块中,允许其他线程继续执行当前线程睡觉。你也可以用一个简单的python程序来测试它:
import time from threading import Thread class worker(Thread): def run(self): for x in xrange(0,11): print x time.sleep(1) class waiter(Thread): def run(self): for x in xrange(100,103): print x time.sleep(5) def run(): worker().start() waiter().start()
哪个会打印:
>>> thread_test.run() 0 100 >>> 1 2 3 4 5 101 6 7 8 9 10 102
标签:targe oat http div 打印 star float 调用 rom
原文地址:https://www.cnblogs.com/pythongood/p/11155104.html