스레드는 파이썬에서 어떻게 구현됩니까? 파이썬은 각 스레드에 대해 별도의 프로세스를 생성합니까?파이썬에서 스레딩 - 스레드 또는 프로세스?
이 코드를 고려하십시오. 그러나 "내부 스레드", 쉘에이 코드를 실행 한 다음 Ctrl + C은 "스레드 외부"인쇄가 오는 중지 일을
from threading import Thread
from time import sleep
class testThread(Thread):
def __init__(self):
Thread.__init__(self)
def run(self):
while True:
print "Thread inner!"
sleep(5)
threadTest = testThread()
threadTest.start()
while True:
print "Thread outer!"
sleep(10)
내가 수동으로 사용하여 죽일 때까지 인쇄되는 계속 '죽일 -9 pid '명령을 사용하십시오.
스레드를 '데몬'으로 설정하십시오. – JBernardo