2012. 7. 18. 16:00

쓰레드를 돌리고 싶은경우 2.7 - > 3.2로 넘어가는 순간 import 되는 것이 thread 에서 _thread 로 변경되엇다.


참조 사이트 : http://docs.python.org/py3k/library/_thread.html?highlight=thread#_thread.start_new_thread



[ example ] 

import _thread, time


g_count = 0


def counter(id,count):

global g_count

for i in range(count):

print ('id %s--> %s' % (id,i))

g_count - g_count +1


_thread.start_new_thread(counter,(1,10000))


time.sleep(3)


print ('total counter = ', g_count)

print ('exit') 


Posted by k1rha