2017-05-18 1 views
0

저는 connect()라고 불리는 함수와 내 계정에 로그인하는 데 사용되는 함수 두 가지를 가지고 있습니다. 또 하나는 내 계정에서 데이터를 가져 오는 identify_2bgval()입니다. 매우 긴 프로세스이므로 멀티 스레딩을 사용하려고했습니다.멀티 스레딩 두 함수

내 질문은 : 나는이 두 기능을 동시에 사용할 수 있습니까? 새 함수를 만든 다음 Threads.use를 사용할 생각입니까? 또한 Thread() 함수로 double 대상을 사용할 수 있습니까? identify_2bgval이를 연결 에 의존하지 않는

run_together(): 
connect() 
identify_2bgval() 
Thread(target= run_together).start() 

답변

0

경우에 당신은 다른 스레드에서 실행할 수 있습니다

def run_together(): 
    t = Thread(target=identify_2bgval) 
    t.start() #2nd thread 
    connect() # main thread waits here ... 
    t.join() # wait for the 2nd thread ... 

#call it ... 
run_together() #blocks until finished ...