쓰레드를 돌리고 싶은경우 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') |
'Python' 카테고리의 다른 글
python socket 작업 중 에러 발생 (0) | 2012.08.17 |
---|---|
[ Python ] 전역변수 설정법 (global value ) ex. thread (0) | 2012.08.09 |
stdout 으로 표준 출력 되는 값을 변수로 저장하여 가져오기. (0) | 2012.07.18 |
[ python 3.2 ] UDP sendto Error 이유와 해결법 (0) | 2012.07.18 |
[ python ] LIST 미리 선언해주기 (0) | 2012.07.16 |