개발자 모드/파이썬(python)

파이썬 python 쓰레드 thread 기본개념 예제

인생은직구 2021. 6. 15. 04:34
728x90
import threading
import time
import sys
import serial
import os
import time

def Task1():
    while True :
        print ('play thread')
        time.sleep(2)




t1= threading.Thread(target= Task1)
t1.start()
while True :
    print('play main')
    time.sleep(5)

main에서 도는 함수와

 

thread에서 도는 함수가 동시에 진행됨을 확인할 수 있다.

 

 

728x90