-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpy_ad_1_3.py
More file actions
37 lines (28 loc) · 913 Bytes
/
py_ad_1_3.py
File metadata and controls
37 lines (28 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
Section 1
Multithreading - Thread(1) - Basic
Keyword - threading basic
"""
import logging
import threading
import time
# 스레드 실행 함수
def thread_func(name):
logging.info("Sub-Thread %s: starting", name)
time.sleep(3)
logging.info("Sub-Thread %s: finishing", name)
# 메인 영역
if __name__ == "__main__":
# Logging format 설정
format = "%(asctime)s: %(message)s"
logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S")
logging.info("Main-Thread : before creating thread")
# 함수 인자 확인
x = threading.Thread(target=thread_func, args=('First',))
logging.info("Main-Thread : before running thread")
# 서브 스레드 시작
x.start()
logging.info("Main-Thread : wait for the thread to finish")
# 주석 전후 결과 확인
# x.join()
logging.info("Main-Thread : all done")