37,719
社区成员
发帖
与我相关
我的任务
分享
import time,thread
lock = thread.allocate_lock()
def myfunction(string,lock,*args):
while 1:
lock.acquire()
print string
lock.release()
if __name__=="__main__":
thread.start_new_thread(myfunction,('a',lock))
thread.start_new_thread(myfunction,('b',lock))
time.sleep(2)
exit(0)