인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

toaehddn's profile image
toaehddn

asked

Python for Advanced Users: Learn the Grammar of Concurrency and Parallelism Feat. Multithreading vs. Multiprocessing (Inflearn Original)

DaemonThread 문의

Written on

·

204

0

안녕하세요.
우선 좋은강의 감사드립니다.
 
Multithreading - Thread(2)의 DaemonThread 관련,
제가 이해하기로는 parent thread가 끝나면, child thread도 바로 끝나버리는, 이 child thread를 DaemonThread로 이해했습니다.
 
그런데 코드를 아래처럼 작성하면, parent thread가 끝나도 (main thread all done 프린트됨), child thread가 살아있습니다.
왜그런건가요??? 제가 editor로 비주얼스튜디오가아니라 주피터를 쓰고있는데... 혹시 이것때문일까요???
 
미리 답변 감사드립니다.
 
[실행코드@주피터 셀]
import threading def thread_func(d): for i in d: print(i) if __name__ == '__main__': x = threading.Thread(target=thread_func, args=(range(10),), daemon=True) x.start() print('main thread all done')
[출력]
0
1
2
3
4
5
6
main thread all done7
8
9
python동시성

Answer 1

1

niceman님의 프로필 이미지
niceman
Instructor

네 터미널이나 ide를 사용해서 테스트 해보세요~~~

toaehddn님의 프로필 이미지
toaehddn
Questioner

감사합니다 강사님. 좋은강의도, 답변도!

toaehddn's profile image
toaehddn

asked

Ask a question