标签:imp world bsp root odi style nbsp locate roo
#!/usr/bin/env python #encoding:utf8 import thread def hello(): for i in xrange(5): w_lock.acquire() print ‘Hello‘, h_lock.release() def world(): for i in xrange(5): h_lock.acquire() print ‘World‘ w_lock.release() lock.release() lock = thread.allocate_lock() lock.acquire() h_lock = thread.allocate_lock() w_lock = thread.allocate_lock() h_lock.acquire() thread.start_new_thread(hello, ()) thread.start_new_thread(world, ()) while lock.locked(): pass
[root@localhost ~]# python 1.py Hello World Hello World Hello World Hello World Hello World
标签:imp world bsp root odi style nbsp locate roo
原文地址:http://www.cnblogs.com/pzk7788/p/7912025.html