|
这是源代码
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import thread as _thread
import time
def counter(myid, count):
for i in range(count):
time.sleep(1)
print '[%s]=>%s'%(_thread.get_ident(), i)
for i in range(5):
_thread.start_new_thread(counter, (i, 5))
time.sleep(6)
print 'Main Thread exiting.'
下面是运行的结果, 刚学python 遇到这种问题不知什么原因,在windows下用相同的代码测试时没有问题
|
|